Skip to content
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

Largest sum of consecutive numbers in an array #162

Open
lelchan opened this issue Oct 29, 2018 · 3 comments
Open

Largest sum of consecutive numbers in an array #162

lelchan opened this issue Oct 29, 2018 · 3 comments
Labels
enhancement New feature or request hacktoberfest-accepted Hacktoberfest! help wanted Extra attention is needed question Further information is requested

Comments

@lelchan
Copy link

lelchan commented Oct 29, 2018

You are given an array with n distinct integers. Design an algorithm that returns two integers i and j, where i <= j, for which the sum of the elements at positions i, (i+1), ....(j-1), j is maximum.
eg. [1, 4, -2, 6, -5, 3] would return 0 and 3, for i and j respectively. The largest sum of consecutive numbers we can get from this array is 9, 1 + 4 - 2 + 6 = 9.

I haven't seen any one line wonders of this yet, but it can be done in O(n) time when solved normally.

@wzhouwzhou wzhouwzhou added help wanted Extra attention is needed question Further information is requested hacktoberfest-accepted Hacktoberfest! labels Oct 29, 2018
@wzhouwzhou wzhouwzhou added the enhancement New feature or request label Oct 29, 2018
gsafcik added a commit to gsafcik/one-line-wonders that referenced this issue Oct 31, 2018
@gsafcik
Copy link
Contributor

gsafcik commented Oct 31, 2018

Well, I think I got it for Python.

wzhouwzhou added a commit that referenced this issue Oct 31, 2018
This was referenced Oct 19, 2019
@yashagarwal1999
Copy link
Contributor

Solved this issue in pull request
#410

yashagarwal1999 added a commit to yashagarwal1999/one-line-wonders that referenced this issue Oct 22, 2019
@yashagarwal1999
Copy link
Contributor

Solved this issue in pull request
#412

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hacktoberfest-accepted Hacktoberfest! help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants