摘要: 思路: 暴力: class Solution { public: int strStr(string haystack, string needle) { if(needle.length() == 0) return 0; bool res = true; int len1 = haystack. 阅读全文
posted @ 2017-06-16 09:31 UniMilky 阅读(111) 评论(0) 推荐(0) 编辑
摘要: 思路: 开始想的是先把特殊符号去掉,但是超时了。事实上直接在遍历中处理就行了。 "参考" class Solution { public: bool isPalindrome(string s) { int left = 0, right = s.length() 1; while(left 阅读全文
posted @ 2017-06-16 08:42 UniMilky 阅读(91) 评论(0) 推荐(0) 编辑
摘要: 思路: 栈的应用。如果是'(','{','[',则只需入栈即可,如果是'}',']',')',则要看栈顶的字符是否和其匹配。 class Solution { public: bool isValid(string s) { stack res; for(int i = 0; i 阅读全文
posted @ 2017-06-16 07:16 UniMilky 阅读(88) 评论(0) 推荐(0) 编辑