Python data engineering interview problem. Difficulty: beginner. Pattern: Arrays. About 10 minutes. Part of the Pro drill bank.
Find all values that appear twice; return sorted. Treat this as a production helper: match the contracted return shape, including empty and duplicate inputs.
Implement find_duplicates(nums: list) -> list for nums where each value is in 1..n and appears once or twice. Return sorted list of values that appear twice.
Input: find_duplicates([4, 3, 2, 7, 8, 2, 3, 1]) Output: [2, 3] 2 and 3 appear twice.
Topics: lakebench, python, duplicates, range.
More Python interview questions · All interview problems · Learn data engineering
Interview-style drill: Find all values that appear twice; return sorted.
Implement `find_duplicates(nums: list) -> list` for nums where each value is in `1..n` and appears once or twice. Return sorted list of values that appear twice. Example: `[4, 3, 2, 7, 8, 2, 3, 1]` → `[2, 3]`. Keep the harness.