Perchwell interview question

Solve a medium programming question live.