I read some online solution using FSM. The code is clear and easy to understand. But I cannot figure out how the 9 states are determined. Can anyone explain to me in detail why it come up with this 9 states? No more no less? I don't know the way to abstract situations into FSM states, which I think is important in the future if I met similar problems that can be solved with FSM very easily.

https://github.com/fuwutu/LeetCode/blob/master/Valid Number.cpp

Thanks!!!