Pergunta de entrevista da empresa DBS Bank

Coding question and how to solve the question