题目:Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2.
这道题十分简单,就是学习字符与数字的转换.
字符-数字:int(str)
数字-字符串:str(n)
代码:
class Solution:
# @param {string} num1 a non-negative integers
# @param {string} num2 a non-negative integers
# @return {string} return sum of num1 and num2
def addStrings(self, num1, num2):
# Write your code here
if len(num1)>5100 or len(num2)>5100:
return None
n1=int(num1)
n2=int(num2)
n=str(n1+n2)
return n