The Output Peak
A hard Python interview practice problem on DataDriven. Write and execute real python code with instant grading.
- Domain
- Python
- Difficulty
- hard
- Seniority
- L5
Problem
Given a list of integers (possibly negative), find the contiguous subarray with the largest sum. Return a 2-element list [sum, subarray]. If multiple subarrays tie for max sum, return the earliest (smallest start index).
Summary
One stretch outpaced all the others.
Practice This Problem
Solve this Python problem with real code execution. DataDriven runs your Python code in a real environment and grades it automatically.