摘要:
用栈保存已经遍历过的内容,但是与数组相比更方便访问、删除离当前访问元素最相邻的已访问元素(数组可以用置位来表示删除)。 class Solution { public: string removeDuplicates(string s) { stack<char> sts; for(int i = 阅读全文
posted @ 2025-03-03 20:55
名字好难想zzz
阅读(30)
评论(0)
推荐(0)
摘要:
编译技术学过 class Solution { public: bool isValid(string s) { stack<char> sts; if( s.size() % 2 != 0) return false; for(int i = 0; i < s.size(); i++) { if( 阅读全文
posted @ 2025-03-03 20:35
名字好难想zzz
阅读(7)
评论(0)
推荐(0)
摘要:
基础题,没啥好说的。唯一需要注意的是栈弹出在入栈会改变顺序,队列不会。 class MyQueue { public: stack<int> m_stIn; stack<int> m_stOut; MyQueue() { } void push(int x) { m_stIn.push(x); } 阅读全文
posted @ 2025-03-03 19:33
名字好难想zzz
阅读(6)
评论(0)
推荐(0)

浙公网安备 33010602011771号