[Python Solution] Special treatment on negative numbers. No mask!
myadd function must work when a, b are both positive or both negative or one of them is zero. When one of a, b is positve and the other is neg, whether myadd fu
`myadd` function must work when `a`, `b` are both positive or both negative or one of them is zero. When one of `a`, `b` is positve and the other is neg, whether `myadd` function works depends on the sum of `a`, `b`. If the sum is neg, `myadd` works fine, otherwise it leads to *TLE* (resulted from how Python store negtive integers).\n\nTherefore, we need special treatment in case of pos+neg=nonneg, namely two cases:\n1) a<0 and a+b>=0; \n2) b<0 and a+b>=0. \n\nIn Case 1, thanks to ~x = -x - 1, `a + b >= 0` can be written as `~a + 1 <= b`  (Of course we have to use `myadd` instead `+` in the code.)  Be careful here `myadd(~a,1)<=b`  cannot be replaced by `myadd(~b,1)<=a` because if ~b=-1`myadd(~b,1)` will lead to *TLE*. Likewise for Case 2.\n\nMoreover, we can take advantage of ~(~a+~b+1) = -((-a-1)+ (-b-1) +1)-1 = a + b and write `~myadd(myadd(~a, ~b), 1)`. As a+b>=0, ~a+~b<=-2, `myadd(~a, ~b)` works as well as `myadd(myadd(~a, ~b), 1)`.\n\nHere\'s the code:\n```\nclass Solution:\n    def getSum(self, a: int, b: int) -> int:\n        def myadd(c, d):\n            while d != 0:\n                c, d = c^d, (c&d)<<1\n            return c\n        if a < 0 and myadd(~a, 1) <= b or b < 0 and myadd(~b, 1) <= a:\n            return ~myadd(myadd(~a, ~b), 1)\n        return myadd(a, b)\n```
['Python']