Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. For example,If n = 4 and k = 2, a solution is: ...
分类:
其他好文 时间:
2016-04-05 19:43:50
阅读次数:
114
Given a string containing only digits, restore it by returning all possible valid IP address combinations. Example Given "25525511135", return [ "255. ...
分类:
其他好文 时间:
2016-04-05 07:07:57
阅读次数:
144
可以用类似于DFS的方法去做。这道题目是LC78 Subsets的子问题。 对于LC78,另一个巧妙的做法是:我们可以先用一个整形数组(长度和nums相等),数组元素一开始都是1。把整个数组看成一个二进制数,然后模拟二进制减法,将这个数组一步一步减1减到0。每减一次1,对照这个二进制数组和nums数 ...
分类:
其他好文 时间:
2016-04-03 17:18:20
阅读次数:
119
是我熟悉的backtracking,但是依旧犯了蠢错误,调了半天 不过尝试了一种:如果不能有重复数字数字的时候,就在主函数里面设一个boolean数字,名字是used,意义如名字显示,当做一个参数传给helper函数 蠢错误在17行,helper(res, item, n, k, i+1)最后一个参 ...
分类:
其他好文 时间:
2016-03-31 07:09:48
阅读次数:
146
Numbers can be regarded as product of its factors. For example, Write a function that takes an integer n and return all possible combinations of its f ...
分类:
其他好文 时间:
2016-03-29 14:52:42
阅读次数:
169
Combinations Total Accepted: 10949 Total Submissions: 36507My Submissions Given two integers n and k, return all possible combinations of k numbers ou ...
分类:
其他好文 时间:
2016-03-27 21:01:51
阅读次数:
218
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. Given n = 3, a solution set is: "((()))", "(()
分类:
其他好文 时间:
2016-03-21 09:22:49
阅读次数:
188
Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. The same repeat
分类:
其他好文 时间:
2016-03-18 00:27:27
阅读次数:
147
Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. For example,If n = 4 and k = 2, a solution is:[[2,4],[3,4],[
分类:
其他好文 时间:
2016-03-16 09:30:14
阅读次数:
88
Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in Cwhere the candidate numbers sums to T. Each numb
分类:
其他好文 时间:
2016-03-16 07:15:49
阅读次数:
146