Answers for "power of two by bit manipulation"

1

power of two by bit manipulation

import java.util.*;

class Solution {
    public boolean solve(int n) {
        if (n == 0)
            return false;

        int ans = n & (n - 1);
        if (ans == 0)
            return true;

        return false;
    }
}
Posted by: Guest on April-19-2021

Browse Popular Code Answers by Language