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.
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 ...
Jan 2, 20263 min read122
