readings, and each value normally arrives exactly three times, since the signal is tripled for reliability. Only one value arrived a single time. Find it.
The readings come in any order. A dictionary solution is easy; try for linear time and O(1) extra memory.readings=[4, -1, 4, 4] → -1
4 shows up three times, -1 only once.
readings=[7, 0, 5, 0, 7, 5, 7, 0, 5, 12] → 12
7, 0 and 5 each appear three times; 12 appears once.
readings=[-30] → -30
readings=[4, -1, 4, 4]
-1
Run checks the first 3 tests in your browser. Submit checks all 86 tests on the server, hidden ones included.