精華區beta Marginalman 關於我們 聯絡資訊
寫完後發現去年5月寫過了 那時候應該是抄某個答案的 結果我一年後再寫一遍 一模一樣 答案直接背起來 笑死 class MyQueue { public: stack<int> in; stack<int> out; MyQueue() { } void push(int x) { in.push(x); } int pop() { if(out.empty()){ while(!in.empty()){ out.push(in.top()); in.pop(); } } int top = out.top(); out.pop(); return top; } int peek() { if(out.empty()){ while(!in.empty()){ out.push(in.top()); in.pop(); } } int top = out.top(); return top; } bool empty() { return in.empty() && out.empty(); } }; -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 61.230.51.220 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1706511744.A.1AF.html
oin1104: 你好棒 01/29 15:03
DaibaNana: 你好厲害 01/29 15:03
JIWP: 大師 01/29 15:03
DJYOSHITAKA: 大濕... 01/29 15:27
pandix: 不是背起來 是你變強了 01/29 16:47