It is also too easy maybe. How can I 开发者_开发知识库fill the B queue by A queue? but B queue must be reverse.
What about just
val b = a.reverse
Assuming Queue is a FIFO, if you can take from the end of the queue, just take from the end of A and put them into B.
If you can't, take A from the front, insert them on a Stack, then when A is empty, put them off the stack into B.
精彩评论