Created
August 4, 2020 23:06
-
-
Save UNISERVO1/a1584d461f38c1a4986b9898b485279c to your computer and use it in GitHub Desktop.
August LeetCoding Challenge Week 1: Day 4
This file contains 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
class Solution { | |
val mask: Int = (0..31 step 2).fold(0){ acc, v -> acc + (1 shl v)} | |
fun isPowerOfFour(num: Int): Boolean { | |
return (num - 1) and num == 0 && (mask and num) > 0 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment