A clean mathematical way though "Time Limit Exceeded"

  • 1

    class Solution(object):
    def getSum(self, a, b):
    return long(math.log(2a2*b)/math.log(2))

    I used the property that log2((2 ** a) * (2 ** b)) = log2(2**(a+b))=a+b. Got "time limit exceeded" though for when a and b are very large.

Log in to reply

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