Detect the Repeated Entry

Intermediate

A submission form should reject a batch if any value appears twice. Report whether a list contains any duplicate.

Implement `solve(List<Integer> nums)` to return true if the list contains any duplicate value, false otherwise.

Examples

Input[1, 2, 3, 2, 5]
Outputtrue
Input[1, 2, 3]
Outputfalse
Hints
  • If a Set built from the list is smaller than the list, there were duplicates.
Anonymous Apex

Your code runs in a secure sandbox against multiple hidden test cases. The problem is solved only when every test passes. Each run is isolated and any data changes are rolled back automatically.