Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing

Contains Duplicate

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

True if any value appears more than once. Treat this as a production helper: match the contracted return shape, including empty and duplicate inputs.

Implement contains_duplicate(nums: list) -> bool.

Requirements

  • Empty list returns False.

Constraints

  • Any type comparable by equality/hash.

Examples

Input: contains_duplicate([1, 2, 3, 1]) Output: True 1 appears twice.

Topics: lakebench, python, set, duplicate.

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

beginner

Contains Duplicate

Interview-style drill: True if any value appears more than once.

Implement `contains_duplicate(nums: list) -> bool`. Example: `[1, 2, 3, 1]` → `True`. Keep the harness.