
dp(Dynamic Programming)
文章平均质量分 52
Crystal_ting
个人博客 limengting.site
展开
-
[4]62. Unique Paths(Java)
A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach the botto原创 2017-09-07 21:46:00 · 344 阅读 · 0 评论 -
?最大子列和问题(Java)/[3]53. Maximum Subarray(Java)
算法1:二重循环,复杂度O(n²)import java.util.Scanner;public class MaxSubSum1 { public static int maxSubSum(int[] array) { int thisSum, maxSum = 0; for (int i = 0; i < array.length; i ++) {原创 2017-07-30 18:53:54 · 343 阅读 · 0 评论 -
64. Minimum Path Sum(Java)
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.Note: You can only move either down or right at any原创 2017-09-28 00:53:16 · 340 阅读 · 0 评论 -
《剑指offer》10.斐波那契数列 / 跳台阶 / 变态跳台阶 / 矩形覆盖
斐波那契数列题目描述 大家都知道斐波那契数列:f(0) = 0, f(1) = 1, f(n) = f(n - 1) + f(n - 2) 现在要求输入一个整数n,请你输出斐波那契数列的第n项。 n&lt;=39思路:如果直接用f(n) = f(n - 1) + f(n - 2)递归,重复计算次数太多,效率低下;用自下而上的循环较好,通过f(0)和f(1)算出f(2),再根据已知的f...原创 2018-03-25 15:46:12 · 274 阅读 · 0 评论 -
《剑指offer》14.剪绳子
题目描述: 给你一根长度为n的绳子,请把绳子剪成m段(m和n都是整数,n &gt; 1,m &gt; 1),每段绳子的长度记为k[0],k[1],k[2]…k[m]。请问k[0] * k[1] * … * k[m]可能的最大乘积是多少?例如,当绳子的长度为8时,我们把它分别剪成2,3,3的三段,此时乘积最大是18。思路一:利用动态规划,自下而上的循环,原理同斐波那契数列,时间复杂度O(n²)...原创 2018-03-28 20:11:14 · 370 阅读 · 0 评论