EXL Service interview question

Coding question based on basic DSA and puzzles