DBS Bank interview question

Coding question and how to solve the question