You are viewing a single comment's thread. Return to all comments →
Go solution:
func birthday(s []int32, d int32, m int32) int32 { var ways int32 = 0 var geralSum int32 = 0 for i, value := range s { geralSum += value segmentSum := s[i] for j := int32(1); j < m; j++ { newIndex := int32(i) + j if newIndex >= int32(len(s)) { break } segmentSum += s[newIndex] } if segmentSum == d { ways += 1 } } if geralSum == m { ways += 1 } return ways }
Seems like cookies are disabled on this browser, please enable them to open this website
Subarray Division
You are viewing a single comment's thread. Return to all comments →
Go solution: