Microsoft Interview Question

Solve a state machine problem