Single Number II on Leetcode


State machine is common and useful technique to be used in algorithm. I really recommend you to figure the last solution out thoroughly. Then try my extended problem!


The programming language in video is C++

For the source code in video: Github


Solution 1 and 2 are similiar to each other, and they both try using 3*n + 1 to separate the single number from the others. Solution 3 uses state machine and truth table to get the answer, with the solution we can even extend to other cases: e.g. my extended practice in video. Help this video can help you go through this challenge.