Question d’entretien chez DBS Bank

Coding question and how to solve the question