摘要: class MyQueue { public: stack<int>stIn; stack<int>stOut; MyQueue() { } void push(int x) { stIn.push(x); } // 从队列开头移除并返回元素 int pop() { if(stOut.empty() 阅读全文
posted @ 2022-11-01 16:48 香花草的味道 阅读(19) 评论(0) 推荐(0)
摘要: 代码示例: class Solution { public: void getNext(int* next, const string& s) { int j = 0; // 初始化;i为后缀末尾; j为前缀末尾; next[0] = 0; for(int i = 1; i < s.size(); 阅读全文
posted @ 2022-11-01 09:50 香花草的味道 阅读(37) 评论(0) 推荐(0)
摘要: 注意查看reverse的使用方法 class Solution { public: string reverseLeftWords(string s, int n) { reverse(s.begin(), s.begin() + n); reverse(s.begin() + n, s.end() 阅读全文
posted @ 2022-11-01 09:43 香花草的味道 阅读(30) 评论(0) 推荐(0)