Solve Binary "Sum of Two Integers"

This is tricky because Python has variable-width integers, so relying on two's
complement to support the sum of negative numbers results in infinite
recursion. I know three ways to combat this:
  1. Use Java.
  2. Conditionally branch and handle either addition or subtraction accordingly.
  3. Use a mask to enforce fixed-width integers in Python.
This commit is contained in:
William Carroll 2020-12-25 03:50:18 +00:00
parent c389b46ecf
commit 4732a7456b

View file

@ -22,7 +22,7 @@
** DONE Container With Most Water
https://leetcode.com/problems/container-with-most-water/
* Binary
** TODO Sum of Two Integers
** DONE Sum of Two Integers
https://leetcode.com/problems/sum-of-two-integers/
** DONE Number of 1 Bits
https://leetcode.com/problems/number-of-1-bits/