add new solutions
This commit is contained in:
parent
ca24d0a56a
commit
0c73608ce5
36 changed files with 791 additions and 0 deletions
23
solutions/34/q3432/solution.go
Normal file
23
solutions/34/q3432/solution.go
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue