Algorithms Playbook
← All problems
EasyHash maps →Similar to: Contains Duplicate

Spot the repeat

Problem

Given an array of integers, return true if some value appears at least twice, and false if every element is distinct.

Examples

Input: [3, 1, 4, 1]

Output: true

1 appears twice.

Input: [2, 7, 9]

Output: false

Hints

    Try it first. Every hint reveals a bit more.

    Solution