Code:public class Solution { public List restoreIpAddresses(String s) { List list = new ArrayList(); int len = s.length(); if(...
分类:
其他好文 时间:
2016-01-25 08:44:45
阅读次数:
138
We can find the regular pattern in gray code, which is:the first of the combinations of n-digit gray code is exactly the combinations of (n-1)-digit g...
分类:
其他好文 时间:
2016-01-24 11:29:48
阅读次数:
109
Based on the combinations problem, we use a for loop to call the method created in that problem and this problem will be solved. Later we'll add bit m...
分类:
其他好文 时间:
2016-01-22 13:43:25
阅读次数:
177
Code:public class Solution { public static String getPermutation(int n, int k) { String result = ""; if(n == 1) return result + 1; ...
分类:
其他好文 时间:
2016-01-20 07:38:03
阅读次数:
120
代码:public class Solution { List> resultList = new ArrayList(); boolean flag = false; public List> permute(int[] nums) { int len = nums...
分类:
其他好文 时间:
2016-01-18 11:52:15
阅读次数:
137
添加两个List:List listSum 存储对应组合的和;List> list 存储可能的组合resultList存储和==target的组合代码:public class Solution { public List listSum; public List> list; p...
分类:
其他好文 时间:
2016-01-17 13:36:31
阅读次数:
151
Sept. 10, 2015 Study again the back tracking algorithm using recursive solution, rat in maze, a classical problem. Made a few of mistakes through the ...
分类:
其他好文 时间:
2015-09-14 07:07:16
阅读次数:
198
Just don't be scared by this problem :-) It's also very standard backtracking problem. This post shares a very concise code, which is rewritten below ...
分类:
其他好文 时间:
2015-09-08 18:33:35
阅读次数:
226
回溯法是分治穷举搜索的一个方法。有点绕人,我复制wiki的解释如下: 回溯法(英语:backtracking)是暴力搜寻法中的一种。 回溯法采用试错的思想,它尝试分步的去解决一个问题。在分步解决问题的过程中,当它通过尝试发现现有的分步答案不能得到有效的正确的解答的时候,它将取消上一步甚至是上几步的计...
分类:
其他好文 时间:
2015-08-08 19:50:10
阅读次数:
206
Well, a typical backtracking problem. The code is as follows. You may walk through it using the example in the problem statement to see how it works. ...
分类:
其他好文 时间:
2015-07-12 00:14:13
阅读次数:
211