File tree 2 files changed +17
-0
lines changed
2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change
1
+ struct Solution ;
2
+
3
+ impl Solution {
4
+ pub fn is_power_of_four ( num : i32 ) -> bool {
5
+ return num > 0 && ( num & ( num - 1 ) ) == 0 && ( num & 0b1010101010101010101010101010101 != 0 ) ;
6
+ }
7
+ }
8
+
9
+ #[ test]
10
+ fn test ( ) {
11
+ assert_eq ! ( Solution :: is_power_of_four( 16 ) , true ) ;
12
+ assert_eq ! ( Solution :: is_power_of_four( 5 ) , false ) ;
13
+ }
Original file line number Diff line number Diff line change @@ -14,6 +14,8 @@ mod _0001_two_sum;
14
14
//
15
15
mod _0002_add_two_numbers;
16
16
//
17
+ mod _0003_longest_substring_without_repeating_characters;
18
+ //
17
19
mod _0005_longest_palindromic_substring;
18
20
//
19
21
mod _0007_reverse_integer;
@@ -100,6 +102,8 @@ mod _0268_missing_number;
100
102
//
101
103
mod _0283_move_zeroes;
102
104
//
105
+ mod _0342_power_of_four;
106
+ //
103
107
mod _0344_reverse_string;
104
108
//
105
109
mod _0347_top_k_frequent_elements;
You can’t perform that action at this time.
0 commit comments