上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 20 下一页
摘要: By far the best solution I have seen is of O(n) time (some solutions claim to be of O(logn)turns out to be O(n)). One of the simplest ideas is to comp... 阅读全文
posted @ 2015-07-06 18:16 jianchao-li 阅读(227) 评论(0) 推荐(0) 编辑
摘要: Well, since theheadpointer may also be modified, we create anew_headthat points to it to facilitate the reverse process.For the example list1 -> 2 -> ... 阅读全文
posted @ 2015-07-06 15:08 jianchao-li 阅读(166) 评论(0) 推荐(0) 编辑
摘要: Well, since theheadpointer may also be modified, we create anew_headthat points to it to facilitate the reverse process.For the example list1 -> 2 -> ... 阅读全文
posted @ 2015-07-06 14:54 jianchao-li 阅读(252) 评论(0) 推荐(0) 编辑
摘要: Well, since theheadpointer may also been modified, we create anew_headthat points to it to facilitate the swapping process.For the example list1 -> 2 ... 阅读全文
posted @ 2015-07-06 14:22 jianchao-li 阅读(180) 评论(0) 推荐(0) 编辑
摘要: 动态规划: 1 class Solution { 2 public: 3 /** 4 * @param s: A string 5 * @param p: A string includes "?" and "*" 6 * @return: A boolean... 阅读全文
posted @ 2015-07-06 12:06 jianchao-li 阅读(219) 评论(0) 推荐(0) 编辑
摘要: Well, so many people has tried to solve this problem using DP. And almost all of them get TLE (if you see aC++DP solution that gets accepted, please l... 阅读全文
posted @ 2015-07-06 11:57 jianchao-li 阅读(241) 评论(0) 推荐(0) 编辑
摘要: Well, the idea of this problem is actually very sample --- keep merging the unmerged lists in lists until there is exactly one list remained. However,... 阅读全文
posted @ 2015-07-06 00:49 jianchao-li 阅读(165) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public: 3 /** 4 * @param s: A string 5 * @param p: A string includes "." and "*" 6 * @return: A boolean 7 ... 阅读全文
posted @ 2015-07-05 23:53 jianchao-li 阅读(295) 评论(0) 推荐(0) 编辑
摘要: This problem has a typical solution using Dynamic Programming. We define the state P[i][j] to be true if s[0..i) matches p[0..j) and false otherwise. ... 阅读全文
posted @ 2015-07-05 23:40 jianchao-li 阅读(408) 评论(0) 推荐(0) 编辑
摘要: To be honest, I do not know whether this problem is designed to let you use stacks. Anyway, I don't. Here are my codes, both BFS and DFS version. 1 ... 阅读全文
posted @ 2015-07-04 10:57 jianchao-li 阅读(227) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public: 3 /** 4 * @param A: An integer array. 5 * @param B: An integer array. 6 * @return: a double whose for... 阅读全文
posted @ 2015-07-03 23:33 jianchao-li 阅读(333) 评论(0) 推荐(0) 编辑
摘要: This link has a very concise and fast solution based on binary search. Spend some time reading it and make sure you understand it. It is very helpful.... 阅读全文
posted @ 2015-07-03 23:20 jianchao-li 阅读(209) 评论(0) 推荐(0) 编辑
摘要: This is a tough problem! I read some solutions from the web. This link provides a one-end BFS solution. The code is reorganized as follows. 1 class So... 阅读全文
posted @ 2015-07-03 16:05 jianchao-li 阅读(340) 评论(0) 推荐(0) 编辑
摘要: This is a classic problem of Dynamic Programming. We define the statedp[i][j]to be the minimum number of operations to convertword1[0..i - 1]toword2[0... 阅读全文
posted @ 2015-07-02 22:12 jianchao-li 阅读(199) 评论(0) 推荐(0) 编辑
摘要: The idea to solve this problem is to first sort the intervals according to theirstartfield and then scan the intervals from head to tail and merge tho... 阅读全文
posted @ 2015-07-02 18:43 jianchao-li 阅读(252) 评论(0) 推荐(0) 编辑
上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 20 下一页