My python solution,simple to understand,but not the best


  • 0
    R

    '''
    class Solution(object):
    def addStrings(self, num1, num2):
    """
    :type num1: str
    :type num2: str
    :rtype: str
    """
    rnum1 = 0
    rnum2 = 0
    len_num1 = len(num1)
    len_num2 = len(num2)
    for i in range(len_num1):
    rnum1 += int(num1[i]) * 10 ** (len_num1 - 1 - i)
    for j in range(len_num2):
    rnum2 += int(num2[j]) * 10 ** (len_num2 - 1 - j)
    res = rnum1 + rnum2
    return str(res)
    '''


  • 0
    R

    I dont know why there is no indentation when I copy my code into this.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.