Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing

Remove Duplicates Preserving Order

Python data engineering interview problem. Difficulty: beginner. Pattern: Arrays. About 10 minutes. Free to practice.

Keep first occurrence of each value and drop later duplicates. Treat this as a production helper: match the contracted return shape, including empty and duplicate inputs.

Implement unique_preserve(nums: list) -> list returning unique values in first-seen order.

Requirements

  • Preserve first-seen order.
  • Empty input returns [].
  • Order-preserving unique list.

Examples

Input: unique_preserve([1, 2, 1, 3, 2]) Output: [1, 2, 3] Later 1 and 2 are dropped.

Topics: lakebench, python, dedupe, order.

More Python interview questions · All interview problems · Learn data engineering

beginner

Remove Duplicates Preserving Order

Interview-style drill: Keep first occurrence of each value and drop later duplicates.

Implement `unique_preserve(nums: list) -> list` returning unique values in first-seen order. Example: `[1, 2, 1, 3, 2]` → `[1, 2, 3]`. Keep the harness.