Python data engineering interview problem. Difficulty: beginner. Pattern: Dynamic Programming. About 10 minutes. Free to practice.
Maximum sum of any contiguous subarray (Kadane). Treat this as a production helper: match the contracted return shape, including empty and duplicate inputs.
Implement max_subarray(nums: list) -> int returning the maximum subarray sum. (subarray [4, -1, 2, 1]).
Input: max_subarray([-2, 1, -3, 4, -1, 2, 1, -5, 4]) Output: 6 Best window is 4,-1,2,1.
Topics: lakebench, python, kadane, subarray.
More Python interview questions · All interview problems · Learn data engineering
Interview-style drill: Maximum sum of any contiguous subarray (Kadane).
Implement `max_subarray(nums: list) -> int` returning the maximum subarray sum. Example: `[-2, 1, -3, 4, -1, 2, 1, -5, 4]` → `6` (subarray `[4, -1, 2, 1]`). Keep the harness.