Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public int getSum(int a, int b) {
- while (b!=0){
- int temp= (a&b)<<1;
- a=a^b;
- b=temp;
- }
- return a;
- }
- }
- //Recursive
- int getSum(int a, int b) {
- return b==0? a:getSum(a^b, (a&b)<<1); //be careful about the terminating condition;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement