- 博客(7)
- 收藏
- 关注
原创 递归——LeetCode47. Permutation II
题目:Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2] have the following unique permutations:[1,1,2], [1,2,1], and
2016-04-19 14:13:26
259
原创 递归——LeetCode46. Permutation
题目:Given a collection of distinct numbers, return all possible permutations.For example,[1,2,3] have the following permutations:[1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], and [3,2,
2016-04-13 16:10:56
283
原创 递归——0-1 Knapsack
最基础的0-1背包问题题目:Given a knapsack which can hold s pounds of items, and a set of items with weight w1, w2, ... wn. Returnwhether we can pick specific items so that their total weight s.Example In
2016-04-13 15:28:27
532
原创 递归——Maze
1. 题目:Given a maze and a start point and a target point, return whether the target can be reached.需要实现的递归函数的接口是:public static boolean solveMaze(char[][] maze, int startX, int startY, int targetX,
2016-04-13 14:16:28
441
原创 递归——LeetCode203. Remove Linked List Elements
题目:Remove all elements from a linked list of integers that have value val.ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 --> 2 --> 3 --> 4 --> 5分析:仍然依照递归的解题思路,
2016-04-13 13:54:14
227
原创 递归——Hanoi塔问题
题目:Hanoi塔问题,游戏规则:(1). 每次只能移动一只圆盘 (2). 任何时候大圆盘不能压在小圆盘之上 (3). 任何时候都不允许将圆盘放在三根立轴之外的任何地方。分析:递归的 base case:当只有一个圆盘的时候,直接从圆盘所在的立轴移动到目标立轴,即完成。递归的 recursion rule:如图所示,要将n个圆盘从立轴A移动到立轴
2016-04-12 18:07:37
461
原创 递归——LeetCode70. Climbing Stairs
题目:You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?分析:Climbi
2016-04-12 17:04:34
254
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅