Power of Four
Given an integer n
, return true
if it is a power of four. Otherwise, return false
.
An integer n
is a power of four, if there exists an integer x
such that n == 4x
.
Example 1:
1 | Input: n = 16 |
Example 2:
1 | Input: n = 5 |
Example 3:
1 | Input: n = 1 |
时间复杂度:O(logn)
空间复杂度:O(1)
1 | class Solution { |
二进制中1的位置:
时间复杂度:O(1)
空间复杂度:O(1)
1 | class Solution { |
取模性质:
时间复杂度:O(1)
空间复杂度:O(1)
1 | class Solution { |