231. Power of Two
Input: n = 1
Output: true
Explanation: 20 = 1Input: n = 16
Output: true
Explanation: 24 = 16Input: n = 3
Output: falseInput: n = 4
Output: trueInput: n = 5
Output: falseLast updated
Input: n = 1
Output: true
Explanation: 20 = 1Input: n = 16
Output: true
Explanation: 24 = 16Input: n = 3
Output: falseInput: n = 4
Output: trueInput: n = 5
Output: falseLast updated
# @param {Integer} n
# @return {Boolean}
def is_power_of_two(n)
return false if n <= 0
return true if n == 1
n.to_s(2).count('1') == 1 ? true : false
end