My python solution


  • 0
    A
    def addStrings(self, num1, num2):
        """
        :type num1: str
        :type num2: str
        :rtype: str
        """
        len1 = len(num1)
        len2 = len(num2)
        result = 0
        for i in xrange(len1):
            result += (ord(num1[i]) - 48 ) * 10 ** (len1 - i - 1)
        for i in xrange(len2):
            result += (ord(num2[i]) - 48 ) * 10 ** (len2 - i - 1)
        return str(result)

Log in to reply
 

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