You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lavos/cap3/work22.go

14 lines
306 B

7 months ago
package cap3
func Work22(nums []int) int {
size := len(nums)
maxSum := 0
for i := size; i < size*2; i++ {
i1, i2, i3, i4 := (i-1)%size, i%size, (i+2)%size, (i+2)%size
sum := nums[i1] + nums[i2] + nums[i3] + nums[i4]
maxSum = max(maxSum, sum)
}
return maxSum
}