Skip to content

Instantly share code, notes, and snippets.

@UNISERVO1
Created August 4, 2020 23:06
Show Gist options
  • Save UNISERVO1/a1584d461f38c1a4986b9898b485279c to your computer and use it in GitHub Desktop.
Save UNISERVO1/a1584d461f38c1a4986b9898b485279c to your computer and use it in GitHub Desktop.
August LeetCoding Challenge Week 1: Day 4
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