BNY interview question

Asked to write code in hackathon