371 . Sum of Two Integers
Easy
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.
0ms:
public int getSum(int a, int b) {
int re = a^b;
int jin = (a&b)<<1;
if(jin!=0) return getSum(re,jin);
return re;
}
2 . Add Two Numbers
Medium
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.
Input: (2 -> 4 -> 3) + (5 -> 6 -> 4)
Output: 7 -> 0 -> 8