Would like to know if this method is valid. Gives me around 50ms run time.


  • 0
     def multiply(self, n1, n2):
        z=48
        a1=0
        a2=0
        a=[ord(val)-48 for val in n1]
        for val in a:
            a1=a1*10+val
        b = [ord(val) - 48 for val in n2]
        for val in b:
            a2 = a2 * 10 + val
        return str(a2*a1)

Log in to reply
 

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