Deutsche Bank Interview Question

Understanding of the logic building for the coding