TrainerRoad interview question

Online algorithm test