摘要:
没考虑到nRows == 1的情况,少数次过 1 class Solution { 2 public: 3 string convert(string s, int nRows) { 4 // Start typing your C/C++ solution below 5 ... 阅读全文
摘要:
自己的思路对的,一直过不了large是因为把visit的建立放在循环最里层,导致每次都建一个两维vector耗了大量的时间。太傻逼了。。 1 class Solution { 2 public: 3 bool dfs(string word, int dep, int maxdep, vec... 阅读全文
摘要:
直接看答案。。 1 class Solution { 2 public: 3 int ladderLength(string start, string end, unordered_set<string> &dict) { 4 // Start typing your C/C++ solution below 5 // DO NOT write int main() function 6 if (start.size() != end.size() || !dict.size()) return 0; 7 int dis... 阅读全文
摘要:
这题第一次做用dfs,结果过不了large,网上寻找到答案,这里s和p指针是会变的,重点处理ptr遇到*的时候,这个时候s和p都往后挪,p重新定位,看s后面和p后面的是不是match,如果不match则s向后移,再继续看后面的是不是match,直到s到底为止,这里str和ptr是浮动指针,s和p相对静止,记录前一个邵点。 1 class Solution { 2 public: 3 bool isMatch(const char *s, const char *p) { 4 // Start typing your C/C++ solution below 5 ... 阅读全文