Solved LeetCode program · 137 of 1,000
#0137 · Single Number II
Original English source
Keep a shared numbers holding 2, 2, 3, and 2. Keep a shared occurrences of 0. Keep a shared lastindex of 3.
To count from spot (a whole number) with target (a whole number). If spot is more than lastindex, return. If item spot of numbers is target, add 1 to occurrences. Count from spot plus 1 with target.
For each candidate in numbers.
Set occurrences to 0. Count from 0 with candidate. If occurrences is 1, show candidate.
Expected stdout
3