package com.fishercoder.solutions;

/**231. Power of Two
 *
 * Given an integer, write a function to determine if it is a power of two.*/

public class _231 {
    public boolean isPowerOfTwo(int n) {
        //after writing out the binary representation of some numbers: 1,2,4,8,16,32, you can easily figure out that
        //every number that is power of two has only one bit that is 1
        //then we can apply that cool trick that we learned from {@link easy._191}: n&(n-1) which will clear the least significant bit in n to zero
        return n > 0 && (n & (n - 1)) == 0;
    }

    public static void main(String... strings) {
        _231 test = new _231();
        System.out.println(test.isPowerOfTwo(14));
    }
}

@@ -32,16 +32,20 @@
 ns;%0A%0A/**
+%0A * 
 231. Pow
@@ -132,16 +132,18 @@
  of two.
+%0A 
 */%0A%0Apubl
@@ -158,16 +158,56 @@
  _231 %7B%0A
+    public static class Solution1 %7B%0A    
     publ
@@ -247,16 +247,20 @@
         
+   
+ 
 //after 
@@ -368,16 +368,20 @@
         
+    
 //every 
@@ -443,16 +443,20 @@
         
+ 
+   
 //then w
@@ -595,16 +595,20 @@
         
+   
+ 
 return n
@@ -643,142 +643,13 @@
     
-%7D%0A%0A
     
-public static void main(String... strings) %7B%0A        _231 test = new _231();%0A        System.out.println(test.isPowerOfTwo(14));
+%7D
 %0A   

refactor 231