Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution:
- def addStrings(self, num1: str, num2: str) -> str:
- x,y,r=deque(),deque(),deque()
- for i in num1:
- x.append(int(i))
- for i in num2:
- y.append(int(i))
- carry=0
- while x or y or carry:
- a=x.pop() if x else 0
- b=y.pop() if y else 0
- res=a+b+carry
- carry,res=divmod(res,10)
- r.appendleft(str(res))
- return "".join(r)
Add Comment
Please, Sign In to add comment