Pergunta de entrevista da empresa EXL Service

Coding question based on basic DSA and puzzles