Python data engineering interview problem. Difficulty: beginner. Pattern: Arrays. About 10 minutes. Free to practice.
Max profit from one buy and one later sell. Treat this as a production helper: match the contracted return shape, including empty and duplicate inputs.
Implement max_profit(prices: list) -> int for one transaction. (buy 1, sell 6).
Input: max_profit([7, 1, 5, 3, 6, 4]) Output: 5 Buy at 1, sell at 6.
Topics: lakebench, python, profit, scan.
More Python interview questions · All interview problems · Learn data engineering
Interview-style drill: Max profit from one buy and one later sell.
Implement `max_profit(prices: list) -> int` for one transaction. Example: `[7, 1, 5, 3, 6, 4]` → `5` (buy 1, sell 6). Keep the harness.