标签:
LeetCode 232 Implement Queue using Stacks
class Queue { stack<int> input, output; public: void push(int x) { input.push(x); } void pop(void) { peek(); output.pop(); } int peek(void) { if (output.empty()) while (input.size()) output.push(input.top()), input.pop(); return output.top(); } bool empty(void) { return input.empty() && output.empty(); } };
LeetCode 232 Implement Queue using Stacks
标签:
原文地址:http://www.cnblogs.com/walker-lee/p/4987427.html