Array
53. Maximum Subarray
Kadane's algorithm, and the insight is almost aggressively simple: the moment your running sum goes negative, throw it away. A negative prefix can only drag down whatever subarray follows, so…
Loading…
Kadane's algorithm, and the insight is almost aggressively simple: the moment your running sum goes negative, throw it away. A negative prefix can only drag down whatever subarray follows, so…
Loading…