Skip to content

Commit

Permalink
Time: 71 ms (54.90%) | Memory: 53.1 MB (29.38%) - LeetSync
Browse files Browse the repository at this point in the history
  • Loading branch information
ShatilKhan committed Feb 19, 2024
1 parent 5253e0e commit 034a7da
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions 231-power-of-two/power-of-two.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* @param {number} n
* @return {boolean}
*/
var isPowerOfTwo = function(n) {
let solution = new Solution();
return solution.isPowerOfTwo(n);
};

class Solution {
isPowerOfTwo(n) {
for (let i = 0; i < 31; i++) {
let ans = Math.pow(2, i);
if (ans === n) {
return true;
}
}
return false;
}
}

0 comments on commit 034a7da

Please sign in to comment.