YASH Technologies interview question

Asked to write code for a given scenarios in second technical round