Solvarch
DSA ProblemsProgressPlanRoadmapsReviewCheat SheetsCompaniesSystem DesignCS FundamentalsQuestion Bank
Theme
Problems

Contains Duplicate

Easy
arrayhash-tablesorting

Given an integer array nums, return true if any value appears at least twice, and false if every element is distinct.

Input: one line of space-separated integers. Output: true or false.

Example 1
Input:
1 2 3 1
Output:
true

1 appears twice.

Example 2
Input:
1 2 3 4
Output:
false

All distinct.

Constraints

  • 1 ≤ nums.length ≤ 10^5
  • -10^9 ≤ nums[i] ≤ 10^9
Watch a video walkthrough

Run your code against the sample tests, or Submit to run the full suite.