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

g2501_2600.s2568_minimum_impossible_or.Solution.kt Maven / Gradle / Ivy

There is a newer version: 1.30
Show newest version
package g2501_2600.s2568_minimum_impossible_or

// #Medium #Array #Bit_Manipulation #Brainteaser
// #2023_07_09_Time_468_ms_(100.00%)_Space_52.2_MB_(100.00%)

class Solution {
    fun minImpossibleOR(nums: IntArray): Int {
        val pow2s = nums.filter {
            it and (it - 1) == 0
        }.toSet()
        return 1 shl (0..31).first {
            (1 shl it) !in pow2s
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy