DP
N.C_IPOC_BUPT
一个喜欢科怀.莱昂纳德的准程序猿,研一在读。
展开
-
96. Unique Binary Search Trees
题目描述 方法思路 这是一个动态规划问题; class Solution { //Runtime: 0 ms, faster than 100.00% //Memory Usage: 31.7 MB, less than 100.00% public int numTrees(int n) { if(n == 0 || n == 1) return 1;...原创 2019-03-21 12:17:48 · 93 阅读 · 0 评论 -
95. Unique Binary Search Trees II
题目描述 方法思路 class Solution{ //Runtime: 2 ms, faster than 68.65% //Memory Usage: 37.1 MB, less than 99.04% public List<TreeNode> generateTrees(int n) { if(n == 0) return new A...原创 2019-03-21 15:53:14 · 105 阅读 · 0 评论 -
213. House Robber II
题目描述 题目链接 https://leetcode.com/problems/house-robber-ii/ 方法思路 class Solution { //Runtime: 0 ms, faster than 100.00% //Memory Usage: 35.5 MB, less than 94.44% public int rob(int[] nums) { ...原创 2019-03-29 15:59:01 · 97 阅读 · 0 评论 -
337. House Robber III
题目描述 The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the “root.” Besides the root, each house has one and only one parent house. After a...原创 2019-03-30 20:12:47 · 109 阅读 · 0 评论 -
198. House Robber 关于动态规划问题(Dynamic programming)的学习、思考与记录
动态规划(Dynamic programming) 定义 任何数学递推公式都可以直接转换为递归算法,但是基本现实是编译器常常不能正确对待递归算法,结果导致低效的程序。当怀疑出现这样的情况时,我们必须再给编译器提供一些帮助,即将递归算法转换为非递归算法,让后者把那些子问题的答案系统的记录在一个表内。利用这种方法的一种技巧叫做动态规划。 以LeetCode.198. House Robber为例进行一...翻译 2019-03-28 22:37:15 · 155 阅读 · 0 评论