Capital One interview question

coding question - tennis game.