Pine Labs interview question

few puzzles