题解 | #不用加减乘除做加法#
不用加减乘除做加法
https://www.nowcoder.com/practice/59ac416b4b944300b617d4f7f111b215
public class Solution { public int Add(int num1, int num2) { while (num2 != 0) { int c = (num1 & num2) << 1; num1 = num1 ^ num2; num2 = c; } return num1; } }
解题思想:位运算
#算法##算法笔记#