Greatest subsequential sum: Difference between revisions

Content added Content deleted
Line 1,262: Line 1,262:
end
end
end
end
</lang>


#a better answer would run in O(n) using
A better answer would run in O(n) instead of O(n^2) using numerical properties to remove the need for the inner loop.
# numerical properties to remove the need for an inner loop.


<lang ruby>
# the trick is that at any point
# the trick is that at any point
# in the iteration if starting a new chain is
# in the iteration if starting a new chain is