ZS Associates interview question

puzzles from gfg and case study