lc-go/solutions/34/q3432/solution.go
2026-01-13 00:14:04 +09:00

23 lines
282 B
Go

package q3432
func countPartitions(nums []int) int {
sumR := 0
for i := range nums {
sumR += nums[i]
}
sumL := 0
cnt := 0
for i := range len(nums) - 1 {
sumL += nums[i]
sumR -= nums[i]
if (sumL-sumR)%2 == 0 {
cnt++
}
}
return cnt
}
var _ = countPartitions