Genpact Interview Question

Data Structures related coding question in Python