Amadeus Interview Question

Debugging a code in hackerrank.