Ctrl K

Largest One of a Kind

Easy
You get an integer array values. Find the largest number that appears in it exactly once. If every number repeats, return -1.
Example 1
values=[6, 2, 11, 6, 11, 4, 2] → 4

11, 6 and 2 each appear twice, while 4 appears once. The answer is 4.

Example 2
values=[3, 3, 3] → -1

The only number repeats, so there is no single value and the answer is -1.

Example 3
values=[0] → 0
Constraints
  • 1 ≤ len(values) ≤ 10⁵
  • 0 ≤ values[i] ≤ 1000
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsThe Candidate With Most Votes EasyDoes Any Value Repeat EasyThe Lost Ticket EasyValues in Both Lists EasyShared Values With Repeats Easy
loading Python…
Input
values=[6, 2, 11, 6, 11, 4, 2]
Expected
4

Run checks the first 3 tests in your browser. Submit checks all 89 tests on the server, hidden ones included.