Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 180
Arrays#115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Arrays #115
Changes from all commits
234e6ba1364709ccf80a60f5a84739fd6954d0ed20f3d5f49e63ed1cc4c0d100ec4f1a469f8b70c13849e144e4cf625bfdb29233618aa57d346df19553d1bf5c53bb034281770a33c749dda9482959f84f4a3cad3f3fd8dfbad78fe3b6dc337e4fecc934ebfeab4e7e3daeba3669527391552646b611f06946dc3File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -2,15 +2,15 @@ importance: 2 | ||
| --- | ||
| # A maximal subarray | ||
| # Максимальний підмасив | ||
| The input is an array of numbers, e.g. `arr = [1, -2, 3, 4, -9, 6]`. | ||
| На вході масив чисел, наприклад `arr = [1, -2, 3, 4, -9, 6]`. | ||
| The task is: find the contiguous subarray of `arr` with the maximal sum of items. | ||
| Завдання: знайти неперервний підмасив `arr` з максимальною сумою елементів. | ||
| Write the function `getMaxSubSum(arr)` that will return that sum. | ||
| Написати функцію `getMaxSubSum(arr)` яка повертає таку суму. | ||
| For instance: | ||
| Наприклад: | ||
| ```js | ||
| getMaxSubSum([-1, *!*2, 3*/!*, -9]) == 5 (the sum of highlighted items) | ||
| @@ -21,10 +21,10 @@ getMaxSubSum([*!*100*/!*, -9, 2, -3, 5]) == 100 | ||
| getMaxSubSum([*!*1, 2, 3*/!*]) == 6 (take all) | ||
Collaborator There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Будь ласка, перекладіть коментарі в коді вище. | ||
| ``` | ||
| If all items are negative, it means that we take none (the subarray is empty), so the sum is zero: | ||
| Якщо всі елементи менші нуля, нічого не беремо, це означає, що підмасив пустий, а сума рівна нулю: | ||
| ```js | ||
| getMaxSubSum([-1, -2, -3]) = 0 | ||
| ``` | ||
| Please try to think of a fast solution: [O(n<sup>2</sup>)](https://en.wikipedia.org/wiki/Big_O_notation) or even O(n) if you can. | ||
| Будь ласка, подумайте над швидким рішенням: [O(n<sup>2</sup>)](https://uk.wikipedia.org/wiki/Нотація_Ландау) або навіть над рішенням O(n), якщо зможете. | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Будь ласка, перекладіть також коментарі в коді вище.