File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change 74
74
273|[ Integer to English Words] ( ./0273-integer-to-english-words.js ) |Hard|
75
75
283|[ Move Zeroes] ( ./0283-move-zeroes.js ) |Easy|
76
76
326|[ Power of Three] ( ./0326-power-of-three.js ) |Easy|
77
+ 342|[ Power of Four] ( ./0342-power-of-four.js ) |Easy|
77
78
345|[ Reverse Vowels of a String] ( ./0345-reverse-vowels-of-a-string.js ) |Easy|
78
79
347|[ Top K Frequent Elements] ( ./0347-top-k-frequent-elements.js ) |Medium|
79
80
349|[ Intersection of Two Arrays] ( ./0349-intersection-of-two-arrays.js ) |Easy|
Original file line number Diff line number Diff line change
1
+ /**
2
+ * 342. Power of Four
3
+ * https://leetcode.com/problems/power-of-four/
4
+ * Difficulty: Easy
5
+ *
6
+ * Given an integer n, return true if it is a power of four. Otherwise, return false.
7
+ *
8
+ * An integer n is a power of four, if there exists an integer x such that n == 4x.
9
+ */
10
+
11
+ /**
12
+ * @param {number } n
13
+ * @return {boolean }
14
+ */
15
+ var isPowerOfFour = function ( n ) {
16
+ if ( n > 1 ) {
17
+ while ( n % 4 === 0 ) {
18
+ n /= 4
19
+ }
20
+ }
21
+ return n === 1 ;
22
+ } ;
You can’t perform that action at this time.
0 commit comments