Re: [LeetCode] 刷到面試 Grind169 C++已回收

看板Marginalman作者 (彗星雷達)時間2年前 (2023/03/19 17:09), 編輯推噓1(101)
留言2則, 2人參與, 2年前最新討論串14/14 (看更多)
232. Implement Queue using Stacks easy題 這好簡單 剛好開始的時候寫完 趕緊來看 class MyQueue { stack<int> in; stack<int> out; public: MyQueue() { } void push(int x) { in.push(x); } int pop() { if(out.empty()){ while(!in.empty()){ out.push(in.top()); in.pop(); } } int temp = out.top(); out.pop(); return temp; } int peek() { if(out.empty()){ while(!in.empty()){ out.push(in.top()); in.pop(); } } return out.top(); } bool empty() { if(in.empty()&&out.empty()) return true; return false; } }; -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 223.137.157.124 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1679216986.A.5A4.html

03/19 17:10, 2年前 , 1F
無情的刷題機器人
03/19 17:10, 1F

03/19 17:16, 2年前 , 2F
問一下 你刷題complexity是implement到甚麼程度才收手
03/19 17:16, 2F
文章代碼(AID): #1a5j5QMa (Marginalman)
討論串 (同標題文章)
文章代碼(AID): #1a5j5QMa (Marginalman)