Subarray with sum closest to 0?

Revision en1, by el3el2, 2015-11-24 02:08:22

I am trying to find an O(n) solution to this problem:

Given an array, find the subarray with the sum closest to 0.

An O(nlogn) solution is kinda straightforward, but I have read this problem in a textbook in a context suggesting there's a O(n) solution. Any help?

Tags #algorithms, subarray

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English el3el2 2015-11-24 02:08:22 304 Initial revision (published)