Open 578223592 opened 4 months ago
题目155,测试case出现: 在网页上没问题
语言:cpp 代码:
// 参考:https://leetcode.cn/problems/min-stack/solutions/242861/zui-yi-dong-yi-ge-zhan-tong-shi-bao-cun-dang-qian-/ // 额外保存包含当前元素的时候栈内最小元素即可 class MinStack { class Node { private: /* data */ public: int val, preMin; }; public: stack<Node> stk_; MinStack() { } void push(int val) { Node node; node.val = val; node.preMin = node.val; if (!stk_.empty()) { node.preMin = min({stk_.top().preMin, node.preMin}); } stk_.push(node); } void pop() { stk_.pop(); } int top() { return stk_.top().val; } int getMin() { return stk_.top().preMin; } };
A clear and concise description of what you expected to happen.(对您期望发生的事情进行清晰简洁的描述。)
Paste here the LeetCode extension log from output channel.(将输出通道中的 LeetCode 扩展日志粘贴到此处。)
Guidance: Press Ctrl+Shift+U, and toggle the channel to LeetCode.(按Ctrl+Shift+U,将频道切换到LeetCode。)
Ctrl+Shift+U
LeetCode
看起来是155题目给的示例格式跟大部分题目不一样
🐛 Bug Report(错误报告)
题目155,测试case出现:
在网页上没问题
To Reproduce(重现)
语言:cpp 代码:
Expected behavior(预期行为)
A clear and concise description of what you expected to happen.(对您期望发生的事情进行清晰简洁的描述。)
Extension Output(扩展输出)
Paste here the LeetCode extension log from output channel.(将输出通道中的 LeetCode 扩展日志粘贴到此处。)
Guidance: Press
Ctrl+Shift+U
, and toggle the channel toLeetCode
.(按Ctrl+Shift+U
,将频道切换到LeetCode
。)Your Environment