Everyone uses a HashSet for LeetCode 961. I found a way to use O(1) space by hacking Moore's Voting Algorithm. Here is the math behind it.
Jan 2 · 3 min read · LeetCode 961: N-Repeated Element in Size 2N Array is usually solved with a simple Hash Set (O(N) space) or randomized checks. But recently, I challenged myself to solve it deterministically using O(1) space. The result? A modified version of Moore’s ...
Join discussion

