![JAR search and dependency download from the Maven repository](/logo.png)
g2301_2400.s2348_number_of_zero_filled_subarrays.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 g2301_2400.s2348_number_of_zero_filled_subarrays
// #Medium #Array #Math #2023_07_01_Time_559_ms_(80.00%)_Space_56_MB_(80.00%)
class Solution {
fun zeroFilledSubarray(nums: IntArray): Long {
var cnt = 0L
var local = 0L
for (n in nums) {
if (n == 0) {
cnt += ++local
} else {
local = 0
}
}
return cnt
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy