上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 21 下一页
摘要: ```C++ /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; ... 阅读全文
posted @ 2018-07-27 22:45 一条图图犬 阅读(468) 评论(0) 推荐(0) 编辑
摘要: ```C++ class Solution { public: bool buddyStrings(string A, string B) { if(A.empty() || B.empty()){ return false; } if(A.size() != B.size()){ return f 阅读全文
posted @ 2018-07-27 16:17 一条图图犬 阅读(379) 评论(0) 推荐(0) 编辑
摘要: ```C++ class Solution { public: int repeatedStringMatch(string A, string B) { string mA; int m=0; while(mA.size() 阅读全文
posted @ 2018-07-27 15:40 一条图图犬 阅读(279) 评论(0) 推荐(0) 编辑
摘要: ```C++ class Solution { public: bool validPalindrome(string s) { int len = s.size(); if(len 阅读全文
posted @ 2018-07-27 13:31 一条图图犬 阅读(279) 评论(0) 推荐(0) 编辑
摘要: ```C++ class Solution { public: int lengthOfLastWord(string s) { auto p = (int)(s.size()-1); string res; while(p>=0 && s[p] == ' '){ p--; } whil... 阅读全文
posted @ 2018-07-27 11:38 一条图图犬 阅读(277) 评论(0) 推荐(0) 编辑
摘要: ```C++ class Solution { public: string prefix2(string& str1, string& str2){ if(str1.empty() || str2.empty()){ return ""; } string res; auto sp1 = str1 阅读全文
posted @ 2018-07-27 11:22 一条图图犬 阅读(619) 评论(0) 推荐(0) 编辑
摘要: ```C++ class Solution { public: bool isValid(string s) { vector stack; map bra; bra[')'] = '('; bra['}'] = '{'; bra[']'] = '['; for(int i=0;i 阅读全文
posted @ 2018-07-26 20:07 一条图图犬 阅读(318) 评论(0) 推荐(0) 编辑
摘要: ```C++ class Solution { public: int firstUniqChar(string s) { map a; for(auto c:s){ if(!a.count(c)){ a[c] = 1; } else{ a[c]++; } } for(int i=0;i 阅读全文
posted @ 2018-07-26 19:30 一条图图犬 阅读(157) 评论(0) 推荐(0) 编辑
摘要: ```C++ class Solution { public: bool repeatedSubstringPattern(string s) { string ss = s + s; string ss_(ss.begin() + 1, ss.end() 1); return (ss_.find( 阅读全文
posted @ 2018-07-26 18:25 一条图图犬 阅读(381) 评论(0) 推荐(0) 编辑
摘要: ```C++ class Solution { public: bool canConstruct(string ransomNote, string magazine) { map r; map m; for(auto i:ransomNote){ if(r[i]==0){ r[i]... 阅读全文
posted @ 2018-07-26 17:35 一条图图犬 阅读(266) 评论(0) 推荐(0) 编辑
上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 21 下一页