VNS Health interview question

Problem i had solved