58. Contains duplicate
Write containsDuplicate nums, which is true when some value appears at least twice in nums, and false when every value is distinct.
Examples
Input: containsDuplicate [1, 2, 3, 1]Output: trueInput: containsDuplicate [1, 2, 3, 4]Output: falseInput: containsDuplicate [1, 1, 1, 3, 3, 4, 3, 2, 4, 2]Output: true
Submitting also runs 7 hidden tests.
Constraints
- The list has at most 500 elements.
Loading editor…
Type
\to in the editor, or click:Run checks your code against the examples and your custom inputs and records nothing. Submit also runs the hidden tests, confirms the axioms your proof uses and records the result. Each uses one compiler check.
ReadyLn 1, Col 1Lean 4
Draft saved in this browser