![JAR search and dependency download from the Maven repository](/logo.png)
g0301_0400.s0319_bulb_switcher.Solution.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of leetcode-in-kotlin Show documentation
Show all versions of leetcode-in-kotlin Show documentation
Kotlin-based LeetCode algorithm problem solutions, regularly updated
package g0301_0400.s0319_bulb_switcher
// #Medium #Math #Brainteaser #2022_11_12_Time_214_ms_(77.78%)_Space_33.4_MB_(55.56%)
class Solution {
fun bulbSwitch(n: Int): Int {
return if (n < 2) {
n
} else Math.sqrt(n.toDouble()).toInt()
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy