Hash Set Pattern — LeetCode #217: Contains Duplicate
typescript
dev.to
Prerequisites: Loop Invariants (to understand why this works, not just how) | Running Sum (#1480) (the accumulator pattern this builds on). If you haven't read them, the solution will still make sense; the invariant section will click deeper if you have. The Problem (15 seconds) Given an integer array, return true if any value appears at least twice. Input: [1, 2, 3, 1] Output: true // 1 appears twice Input: [1, 2, 3, 4] Output: false // all distinct Leet