Using bit manipulation

#1 —>check it out for more details.

I’m using BigInteger here to handle large string value

 import java.math.BigInteger;    
 public class Solution {
public int power(String A) {
    //Properties for numbers which are powers of 2, is that they have one
    //and only one bit set in their binary representation. 
    //If the number is neither zero nor a power of two,
    //it will have 1 in more than one place.
    //So if x is a power of 2 then x & (x-1) will be 0.
    BigInteger x = new BigInteger(A);
      if(x.equals(BigInteger.ZERO) || x.equals(BigInteger.ONE))
    return 0;
    x = x.divide(BigInteger.valueOf(2));
    if (x.equals(BigInteger.ONE))return 1;else return 0;