摘要:
class MyQueue { public: stack<int>stIn; stack<int>stOut; MyQueue() { } void push(int x) { stIn.push(x); } // 从队列开头移除并返回元素 int pop() { if(stOut.empty() 阅读全文
摘要:
代码示例: 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(); 阅读全文
摘要:
注意查看reverse的使用方法 class Solution { public: string reverseLeftWords(string s, int n) { reverse(s.begin(), s.begin() + n); reverse(s.begin() + n, s.end() 阅读全文