Solution for "Sum of Two Integers" using bitwise operators

  • 0

    I thought of a simple solution for this problem using bitwise operators and not using + for doing actual addition as the question intends:

    class Solution(object):
        def getSum(self, a, b):
            :type a: int
            :type b: int
            :rtype: int
            return (a|b) + (a&b)

  • 0

    I guess you should not use '+' anywhere in the code

Log in to reply

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