371. Sum of Two Integers - Medium 前往題目 思路 提取數字(用XOR) 提取carry Code class Solution { public int getSum(int a, int b) { // Until no carry while (b != 0) { int temp = (a & b) << 1; a = a ^ b; b = temp; } return a; } } Leetcode > Medium #Leetcode #心得 #Math #Bit Manipulation 371. Sum of Two Integers - Medium https://f88083.github.io/2024/03/18/371-Sum-of-Two-Integers-Medium/ 作者 Simon Lai 發布於 2024年3月18日 許可協議 199. Binary Tree Right Side View - Medium 上一篇 2013. Detect Squares - Medium 下一篇 Please enable JavaScript to view the comments