minor fixes

This commit is contained in:
Ilya Kantor 2020-02-18 23:46:24 +00:00
parent 9acc1302a1
commit 81def0275e
2 changed files with 8 additions and 8 deletions

View file

@ -10,15 +10,15 @@ The task is: find the contiguous subarray of `arr` with the maximal sum of items
Write the function `getMaxSubSum(arr)` that will return that sum.
For instance:
For instance:
```js
getMaxSubSum([-1, *!*2, 3*/!*, -9]) = 5 (the sum of highlighted items)
getMaxSubSum([*!*2, -1, 2, 3*/!*, -9]) = 6
getMaxSubSum([-1, 2, 3, -9, *!*11*/!*]) = 11
getMaxSubSum([-2, -1, *!*1, 2*/!*]) = 3
getMaxSubSum([*!*100*/!*, -9, 2, -3, 5]) = 100
getMaxSubSum([*!*1, 2, 3*/!*]) = 6 (take all)
getMaxSubSum([-1, *!*2, 3*/!*, -9]) == 5 (the sum of highlighted items)
getMaxSubSum([*!*2, -1, 2, 3*/!*, -9]) == 6
getMaxSubSum([-1, 2, 3, -9, *!*11*/!*]) == 11
getMaxSubSum([-2, -1, *!*1, 2*/!*]) == 3
getMaxSubSum([*!*100*/!*, -9, 2, -3, 5]) == 100
getMaxSubSum([*!*1, 2, 3*/!*]) == 6 (take all)
```
If all items are negative, it means that we take none (the subarray is empty), so the sum is zero:

View file

@ -20,7 +20,7 @@ let users = [
let usersById = groupById(users);
/*
// after the call we have:
// after the call we should have:
usersById = {
john: {id: 'john', name: "John Smith", age: 20}