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

g0401_0500.s0476_number_complement.Solution.kt Maven / Gradle / Ivy

There is a newer version: 1.28
Show newest version
package g0401_0500.s0476_number_complement

// #Easy #Bit_Manipulation #2022_12_31_Time_133_ms_(100.00%)_Space_33.1_MB_(76.47%)

class Solution {
    fun findComplement(num: Int): Int {
        return num.inv() and (Integer.highestOneBit(num) shl 1) - 1
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy