Skip to content

Commit 02a539b

Browse files
committed
add python solution for problem 43
1 parent 4e18c0c commit 02a539b

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class Solution(object):
2+
def multiply(self, num1, num2):
3+
4+
# Create a dictionary to store 0-9 key-value pairs
5+
dict_nums={"0": 0, "1": 1, "2": 2, "3": 3, "4": 4, "5": 5, "6": 6, "7": 7, "8": 8, "9": 9}
6+
number1 = 0
7+
number2 = 0
8+
9+
# Convert num1 in integer format
10+
for i in num1:
11+
key = dict_nums[i]
12+
number1 = (number1 * 10) + key
13+
14+
15+
# Convert num2 in integer format
16+
for i in num2:
17+
key = dict_nums[i]
18+
number2 = (number2 * 10) + key
19+
20+
return str(number1 * number2)

solution/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@
222222
│   └── Solution.py
223223
├── 0043.Multiply Strings
224224
│   └── Solution.java
225+
│   └── Solution.py
225226
├── 0044.Wildcard Matching
226227
│   └── Solution.java
227228
├── 0045.Jump Game II

0 commit comments

Comments
 (0)