Python data engineering interview problem. Difficulty: beginner. Pattern: Hashing. About 10 minutes. Free to practice.
Length of the longest run of consecutive integers. Treat this as a production helper: match the contracted return shape, including empty and duplicate inputs.
Implement longest_consecutive(nums: list) -> int returning the longest consecutive sequence length. (1..4).
Input: longest_consecutive([100, 4, 200, 1, 3, 2]) Output: 4 1,2,3,4 form a run.
Topics: lakebench, python, set, sequence.
More Python interview questions · All interview problems · Learn data engineering
Interview-style drill: Length of the longest run of consecutive integers.
Implement `longest_consecutive(nums: list) -> int` returning the longest consecutive sequence length. Example: `[100, 4, 200, 1, 3, 2]` → `4` (1..4). Keep the harness.