Untitled
class Solution { public: int findComplement(int num) { long long int ans = 0, po = 1; while(num > 0) { int mod = num & 1; if(mod == 0) { ans+=po; } po= po * 2; num/=2; } return ans; } };
Leave a Comment
class Solution { public: int findComplement(int num) { long long int ans = 0, po = 1; while(num > 0) { int mod = num & 1; if(mod == 0) { ans+=po; } po= po * 2; num/=2; } return ans; } };