Skip to the code
cf.
+10 XP

#21 Duplicate Request IDs

easy

Every API request your front end sends carries an id that is supposed to be unique. A bug report says some ids were reused.

Write hasDuplicateIds(ids) that returns true if any id appears more than once in ids, and false otherwise.

Example 1

Input: ids = ["r1","r2","r3","r2"]
Output: true

r2 appears twice.

Example 2

Input: ids = ["a","b","c"]
Output: false

Every id is different.

Constraints

  • 0 <= ids.length <= 10^5
  • Ids are strings.
Saved in this browser

Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.

Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).