Infosys Interview Question

data structure and algorithm hard.