ThoughtSpot interview question

Snake and Ladder Problem