4 / 75
M

Maximum Subarray

#4
arrayhashmap

Use Kadane's algorithm: track max ending here and global max.

Example:

Input:[-2,1,-3,4,-1,2,1,-5,4]
Output:6

Common Mistakes:

  • Off-by-one indexing
  • Not handling edge cases (null/empty)

Notes:

Edge cases: duplicates, empty inputs, negative numbers where applicable.

4/75
Maximum Subarray