AntStack interview question

Asked to do a task