Solve StackQueueUsingHeap.