摘要:
class Solution { public: bool isValid(string s) { int r1 = 0, r2 = 0, r3 = 0; char temp; stack<char> stk; for(int i = 0; i < s.size(); ++i){ if(s[i] =
閱讀全文
摘要:
class MyStack { public: MyStack() : q1(queue<int>()), q2(queue<int>()) { } void push(int x) { q1.push(x); } int pop() { int ret; if(q1.size() == 1){ r
閱讀全文
摘要:
class MyQueue { public: MyQueue() { } void push(int x) { s1.push(x); } int pop() { int ret; if(!empty()){ if(!s2.empty()){ ret = s2.top(); s2.pop(); r
閱讀全文
摘要:
KMP算法一點都不想回憶了,等找實習(xí)的時候再仔細(xì)看吧 class Solution { public: bool repeatedSubstringPattern(string s) { if(s.size() <= 1) return false; string temp = "", str =
閱讀全文
摘要:
決定轉(zhuǎn)前端了。先用c++刷題刷著先 class Solution { public: int strStr(string haystack, string needle) { if(haystack.size() < needle.size()) return -1; for(int i = 0;
閱讀全文
摘要:
#include <iostream> #include <string> using std::cin; using std::cout; using std::endl; using std::string; int main(){ int k; string s; cin >> k; cin
閱讀全文
摘要:
class Solution { public: string reverseStr(string s, int k) { for(int i = 0; i < s.size(); i += 2*k){ if(s.size() - i >= k){ reverse(s, i, i + k -1);
閱讀全文
摘要:
class Solution { public: void reverseString(vector<char>& s) { int head = 0, tail = s.size() -1; while(head < tail){ char temp = s[head]; s[head] = s[
閱讀全文
摘要:
class Solution { public: vector<vector<int>> fourSum(vector<int>& nums, int target) { vector<vector<int>> ans; sort(nums.begin(), nums.end()); long su
閱讀全文
摘要:
practise makes perfect! 相信自己的努力不會白費,繼續(xù)學(xué)習(xí)吧 class Solution { public: vector<vector<int>> threeSum(vector<int>& nums) { vector<vector<int>> ans; sort(num
閱讀全文