We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3fec4f9 commit 3ffc59eCopy full SHA for 3ffc59e
1 file changed
Multiply strings
@@ -0,0 +1,36 @@
1
+def multiply_str(str1,str2):
2
+ len1=len(str1)
3
+ len2=len(str2)
4
+
5
+ str1 = list(map(int,reversed(str1)))
6
+ str2 = list(map(int, reversed(str2)))
7
8
+ res = [0 for i in range(len1+len2)]
9
10
+ for j in range(len2):
11
+ for i in range(len1):
12
13
+ res[i+j] = res[i+j]+str1[i]*str2[j]
14
+ res[i+j+1] = res[i+j+1] +res[i+j]//10 #carry
15
+ res[i+j] = res[i+j] % 10
16
17
+ i=len(res)-1
18
+ while(res[i]==0 and i>0):
19
+ i=i-1
20
21
+ return "".join(map(str,res[:i+1][::-1]))
22
23
24
25
26
27
28
29
30
31
32
33
34
+str1="78"
35
+str2="57"
36
+print(multiply_str(str1,str2))
0 commit comments