Given a string containing only digits, restore it by returning all possible valid IP address combinations.For example:Given"25525511135",return["255.2...
分类:
其他好文 时间:
2014-09-24 21:14:07
阅读次数:
234
https://oj.leetcode.com/problems/combinations/Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.For example,If ...
分类:
编程语言 时间:
2014-09-20 09:58:07
阅读次数:
204
Given a string containing only digits, restore it by returning all possible valid IP address combinations.For example:Given "25525511135",return ["255...
分类:
其他好文 时间:
2014-09-20 07:44:47
阅读次数:
235
[leetcode]Given two integers n and k, return all possible combinations of k numbers out of 1 ... n....
分类:
其他好文 时间:
2014-09-19 10:07:55
阅读次数:
209
本系列博文中有很多两种思路的,其实是因为第一遍刷题的时候有一个想法,第二遍刷题的时候已经忘掉之前的思路了,又有新的想法了。
同时大部分代码我也同时PO到leetcode的对应题目的问答中去了,所以如果你也查看问题讨论的话会发现有和我一模一样的代码,其实就是我PO的:)
书接正文,基于循环的两种思路如下:
第一种思路
比如“234”这个字符串,我可以先将0...1的所有排列找到-->...
分类:
其他好文 时间:
2014-09-16 12:42:30
阅读次数:
145
Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephon...
分类:
其他好文 时间:
2014-09-16 00:05:09
阅读次数:
405
组合数,这题的关键是不能漏解。第一感觉应该是分治法。这里,为了方便叙述,使用一个辅助函数vector> combhelper(int first, int last, int k);含义是从first 到last(左闭右开)的区间中选择K个数的组合数,我们倒过来看,最后一个数(last - 1)或者...
分类:
其他好文 时间:
2014-09-11 20:55:12
阅读次数:
187
//递归结发,计算正确,但是会timeout 1 public class Solution { 2 public List> combine(int n, int k) { 3 int [] num = new int[n+1]; 4 for (int i=...
分类:
其他好文 时间:
2014-09-10 22:24:51
阅读次数:
156
Given two integersnandk, return all possible combinations ofknumbers out of 1 ...n.For example,Ifn= 4 andk= 2, a solution is:[ [2,4], [3,4], [2,3],...
分类:
其他好文 时间:
2014-09-09 21:17:39
阅读次数:
205
Letter Combinations of a Phone Number
Total Accepted: 15964 Total
Submissions: 60700My Submissions
Given a digit string, return all possible letter combinations that the number could repr...
分类:
其他好文 时间:
2014-09-09 13:13:39
阅读次数:
191