1,自己写的又长又臭的代码,也能AC,但是太丑了.主要是通过二进制来算. public static int addAB(int a, int b){ int res = 0; String str1 = Integer.toBinaryString(a); String str2 = Integer.toBinaryString(b); ArrayList<Integer> list = new ArrayList(); int digit = 0; int cur = 0; int i =…
问题: Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -.Example:Given a = 1 and b = 2, return 3. class Solution(object): def getSum(self, a, b): """ :type a: int :type b: int :rtype: int "&quo…
面试题 65. 不用加减乘除做加法 题目描述 题目:写一个函数,求两个整数之和,要求在函数体内不得使用+.-.*./四则运算符号. Java 实现 public class Solution { public int Add(int num1,int num2) { while (num2!=0) { int temp = num1^num2; num2 = (num1&num2)<<1; …