class Solution {
public:
int getSum(int a, int b) {
int total = a;
while (b != 0)
{
total = a ^ b; //calculates sum of 'a' and 'b' without taking carry
b = (a & b) << 1; //calculates the carry
a = total; //add sum(without carry) and carry
}
return total;
}
};
What is the time complexity of the above code ?Plz describe.