Correctly iterate through all elements for cumulative array
This commit is contained in:
parent
c788e9b336
commit
5472d418f5
@ -263,7 +263,7 @@ private fun cumSum(arr: ShortArray): ShortArray {
|
|||||||
val cumArr = ShortArray(arr.size)
|
val cumArr = ShortArray(arr.size)
|
||||||
|
|
||||||
cumArr[0] = arr.first()
|
cumArr[0] = arr.first()
|
||||||
for (index in 1..<arr.size - 1) {
|
for (index in 1..<arr.size) {
|
||||||
cumArr[index] = (arr[index] + cumArr[index - 1]).toShort()
|
cumArr[index] = (arr[index] + cumArr[index - 1]).toShort()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user