Python 3-line solution


  • 1
    S
    class Solution(object):
        def multiply(self, num1, num2):
            """
            :type num1: str
            :type num2: str
            :rtype: str
            """
            num1 = reduce(lambda x, y: x * 10 + y, [ord(i) - 48 for i in num1]) # '0' is 48 in ascii
            num2 = reduce(lambda x, y: x * 10 + y, [ord(i) - 48 for i in num2])
            return str(num1 * num2)

  • 0
    2

    This is not valid because you are converting input into numbers.


Log in to reply
 

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