342. Power of Four Easy
1/**
2 * [342] Power of Four
3 *
4 * Given an integer n, return true if it is a power of four. Otherwise, return false.
5 * An integer n is a power of four, if there exists an integer x such that n == 4^x.
6 *
7 * Example 1:
8 * Input: n = 16
9 * Output: true
10 * Example 2:
11 * Input: n = 5
12 * Output: false
13 * Example 3:
14 * Input: n = 1
15 * Output: true
16 *
17 * Constraints:
18 *
19 * -2^31 <= n <= 2^31 - 1
20 *
21 *
22 * Follow up: Could you solve it without loops/recursion?
23 */
24pub struct Solution {}
25
26// problem: https://leetcode.com/problems/power-of-four/
27// discuss: https://leetcode.com/problems/power-of-four/discuss/?currentPage=1&orderBy=most_votes&query=
28
29// submission codes start here
30
31impl Solution {
32 pub fn is_power_of_four(n: i32) -> bool {
33 false
34 }
35}
36
37// submission codes end
38
39#[cfg(test)]
40mod tests {
41 use super::*;
42
43 #[test]
44 fn test_342() {
45 }
46}
47
Back
© 2025 bowen.ge All Rights Reserved.