more solutions on stack and queue.