题目:Reverse a linked list from positionmton. Do it
in-place and in one-pass.For example:Given1->2->3->4->5->NULL,m=
2 andn= 4,return1->4->3->2->5->NULL...
分类:
其他好文 时间:
2014-06-09 23:03:18
阅读次数:
254
原题地址:https://oj.leetcode.com/problems/combination-sum-ii/题意:Given
a collection of candidate numbers (C) and a target number (T), find all unique
combi...
分类:
编程语言 时间:
2014-06-09 17:41:58
阅读次数:
320
【题目】
Follow up for problem "Populating Next Right Pointers in Each Node".
What if the given tree could be any binary tree? Would your previous solution still work?
Note:
You may only use constant extra space.
For example,
Given the following binary tre...
分类:
其他好文 时间:
2014-06-08 15:46:22
阅读次数:
303
【题目】
Given an index k, return the kth row of the Pascal's triangle.
For example, given k = 3,
Return [1,3,3,1].
Note:
Could you optimize your algorithm to use only O(k) extra space?
【题意】
给定行索引k, k从0开始,返回该索引指向的杨辉三角的行
要求只能使用O(k)的额外空间
【思路】
...
分类:
其他好文 时间:
2014-06-08 15:46:02
阅读次数:
272
题目
Given n, generate all structurally unique BST's (binary search trees) that store values 1...n.
For example,
Given n = 3, your program should return all 5 unique BST's shown below.
...
分类:
其他好文 时间:
2014-06-08 15:15:26
阅读次数:
223
题目:For example, given s = "aab",
Return 1 since the palindrome partitioning ["aa","b"] could be produced using 1 cut
解题思路:给一个字符串,如果字符串可以划分成若干子回文字符串,返回最小的划分数量。
这个题如果还用之前求所有划分组合的循环加递归方法的话,就会得到超时的错误。这是就要考虑别的方法,动态规划倒是一个不错的方法,但是动态规划最重要的是要找到动态方程。本题的动态方程:
dp[i] =...
分类:
其他好文 时间:
2014-06-08 14:56:58
阅读次数:
257
题目
Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).
For example:
Given binary tree {3,9,20...
分类:
其他好文 时间:
2014-06-08 09:23:34
阅读次数:
230
题目
Given a collection of integers that might contain duplicates, S, return all possible subsets.
Note:
Elements in a subset must be in non-descending order.The solution set must not c...
分类:
其他好文 时间:
2014-06-08 05:32:21
阅读次数:
196
HDU1002--A + B Problem II...
分类:
其他好文 时间:
2014-06-08 04:56:06
阅读次数:
242
题目
Given a set of distinct integers, S, return all possible subsets.
Note:
Elements in a subset must be in non-descending order.The solution set must not contain duplicate subsets.
...
分类:
其他好文 时间:
2014-06-08 04:01:05
阅读次数:
240