b*****d 发帖数: 23 | 1 given a unsorted queue,
sort it via using another queue and some variable.
百思不得其解, 望指教。
如果是 stack, 我会做。 | j***e 发帖数: 2428 | 2 stack 怎么做
【在 b*****d 的大作中提到】 : given a unsorted queue, : sort it via using another queue and some variable. : 百思不得其解, 望指教。 : 如果是 stack, 我会做。
| v*****u 发帖数: 1796 | 3 A very inefficiant method:
1. use two queue to calculate the number of elments in queue, say the number
is n
2. use one queue, deque and inque for n times to get the largest number
3. move the largest number into Q2
4. repeat step2, but this time Q1 is one size smaller than before. Until Q1
is empty
【在 b*****d 的大作中提到】 : given a unsorted queue, : sort it via using another queue and some variable. : 百思不得其解, 望指教。 : 如果是 stack, 我会做。
|
|