Third Bridge interview question

quite straightforward