LeetCode solutions by tgic

Power of Two

https://leetcode.com/problems/power-of-two

Last Update 2015-07-06 15:00:26 +0000 View on Github

Source code Read on Github

 1 public class Solution {
 2     public boolean isPowerOfTwo(int n) {
 3         if(n == 0) return false;
 4         if(n == 1) return true;
 5 
 6         if(n % 2 == 1) return false;
 7 
 8         return isPowerOfTwo(n / 2);
 9     }
10 }
comments powered by Disqus

LeetCode solutions by tgic

  • LeetCode solutions by tgic
  • [email protected]
  • Creative Commons License
    This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
  • tg123
  • tg123/leetcode

LeetCode java solutions by tgic