Created
June 8, 2020 07:39
-
-
Save RP-3/bdc2db72e4fc92775c296b4168630cba to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @param {number} n | |
* @return {boolean} | |
*/ | |
var isPowerOfTwo = function(n) { | |
if(n<=0) return false; | |
n&=(n-1); | |
return n === 0; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment