All Downloads are FREE. Search and download functionalities are using the official Maven repository.

g0201_0300.s0231_power_of_two.Solution.kt Maven / Gradle / Ivy

There is a newer version: 1.30
Show newest version
package g0201_0300.s0231_power_of_two

// #Easy #Math #Bit_Manipulation #Recursion #Algorithm_I_Day_13_Bit_Manipulation
// #2022_10_26_Time_161_ms_(86.81%)_Space_33.6_MB_(88.19%)

class Solution {
    fun isPowerOfTwo(n: Int): Boolean {
        return n > 0 && Integer.bitCount(n) == 1
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy