Python data engineering interview problem. Difficulty: beginner. Pattern: Arrays. About 10 minutes. Part of the Pro drill bank.
Find the one duplicated number in 1..n with n+1 entries. Treat this as a production helper: match the contracted return shape, including empty and duplicate inputs.
Implement find_duplicate(nums: list) -> int where nums has n+1 integers in 1..n and exactly one duplicate.
Input: find_duplicate([1, 3, 4, 2, 2]) Output: 2 2 appears twice.
Topics: lakebench, python, duplicate, floyd.
More Python interview questions · All interview problems · Learn data engineering
Interview-style drill: Find the one duplicated number in 1..n with n+1 entries.
Implement `find_duplicate(nums: list) -> int` where nums has n+1 integers in 1..n and exactly one duplicate. Example: `[1, 3, 4, 2, 2]` → `2`. Keep the harness.