SOTI interview question

Queue based problem in coding