Re: [閒聊] 每日LeetCode
寫完後發現去年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
→
01/29 15:03,
4月前
, 1F
01/29 15:03, 1F
推
01/29 15:03,
4月前
, 2F
01/29 15:03, 2F
推
01/29 15:03,
4月前
, 3F
01/29 15:03, 3F
推
01/29 15:27,
4月前
, 4F
01/29 15:27, 4F
→
01/29 16:47,
4月前
, 5F
01/29 16:47, 5F
討論串 (同標題文章)
完整討論串 (本文為第 630 之 719 篇):
閒聊
1
3