Kadane's algorithm
medium 16 minFind the contiguous subarray with the largest sum in one pass.
Kadane: sum with range, all negatives, product and circular
Read it, run it, change a line and run it again.
Loading editor…
max_subarray is the one to write in an interview. The other two are the most common follow-ups.