DBS Bank Interview Question

Coding question and how to solve the question