Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^3: Largest Sum of Consecutive Integers

by JadeNB (Chaplain)
on Oct 13, 2008 at 21:48 UTC ( [id://716866]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Largest Sum of Consecutive Integers
in thread Largest Sum of Consecutive Integers

the largest sum is always going to be: add up all positive integers in the array and exclude negatives. as adding is communicative, order of the array and sequence of the add operation doesn't make any difference.
While this certainly gives the largest sum of a sub(multi)set of the entries of the array, it needn't satisfy the conditions of the problem, since that required the summands to be consecutive terms of the array. (Incidentally, addition is commutative.)
  • Comment on Re^3: Largest Sum of Consecutive Integers

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://716866]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2024-04-18 03:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found