Untitled

mail@pastecode.io avatar
unknown
plain_text
25 days ago
350 B
3
Indexable
Never
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