@@ -10,15 +10,15 @@ The task is: find the contiguous subarray of `arr` with the maximal sum of items
1010
1111Write the function ` getMaxSubSum(arr) ` that will return that sum.
1212
13- For instance:
13+ For instance:
1414
1515``` js
16- getMaxSubSum ([- 1 , * ! * 2 , 3 */ ! * , - 9 ]) = 5 (the sum of highlighted items)
17- getMaxSubSum ([* ! * 2 , - 1 , 2 , 3 */ ! * , - 9 ]) = 6
18- getMaxSubSum ([- 1 , 2 , 3 , - 9 , * ! * 11 */ ! * ]) = 11
19- getMaxSubSum ([- 2 , - 1 , * ! * 1 , 2 */ ! * ]) = 3
20- getMaxSubSum ([* ! * 100 */ ! * , - 9 , 2 , - 3 , 5 ]) = 100
21- getMaxSubSum ([* ! * 1 , 2 , 3 */ ! * ]) = 6 (take all)
16+ getMaxSubSum ([- 1 , * ! * 2 , 3 */ ! * , - 9 ]) == 5 (the sum of highlighted items)
17+ getMaxSubSum ([* ! * 2 , - 1 , 2 , 3 */ ! * , - 9 ]) == 6
18+ getMaxSubSum ([- 1 , 2 , 3 , - 9 , * ! * 11 */ ! * ]) == 11
19+ getMaxSubSum ([- 2 , - 1 , * ! * 1 , 2 */ ! * ]) == 3
20+ getMaxSubSum ([* ! * 100 */ ! * , - 9 , 2 , - 3 , 5 ]) == 100
21+ getMaxSubSum ([* ! * 1 , 2 , 3 */ ! * ]) == 6 (take all)
2222```
2323
2424If all items are negative, it means that we take none (the subarray is empty), so the sum is zero:
0 commit comments