[Leetcode] Unique Paths 唯一路径
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 bottom-right corner of the grid (marked 'Finish' in the diagram below). How many possible unique pat...
2015-08-27
Longest Increasing Subsequence
Longest Increasing SubsequenceGiven an unsorted array of integers, find the length of longest increasing subsequence.
2016-11-21
221. Maximal Square
Given a 2D binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area.
2019-02-21
这是我的第一篇测试文章
221. 最大正方形 思路: 坐标型动态规划,找到规律一切就都迎刃而解了。 话不多说,一图胜千言。 ![fig1] 根据上面可以直接得到状态转移方程,fi代表的是以该位置为正方形的右下角则最大正方形的边长。 时间复杂度O(N M),空间复杂度O(N M) 这题唯一的缺点是输入的元素用的字符串 python3代码 {代码...}
2019-09-09
算法练习
剑指offer题答案笔记1.二维数组中的查找 {代码...} 1.连续子数组的最大和动态规划 {代码...}
2017-11-07
Maximum Subarray leetcode
Find the contiguous subarray within an array (containing at least onenumber) which has the largest sum. For example, given the array [−2,1,−3,4,−1,2,1,−5,4], the contiguoussubarray [4,−1,2,1] has the largest sum = 6.
2016-01-12
动态规划练习题-聚会的欢乐
问题描述:你要组织一个由你公司的人参加的聚会。你希望聚会非常愉快,尽可能多地找些有趣的热闹。但是劝你不要同时邀请某个人和他的上司,因为这可能带来争吵。给定N个人(姓名,他幽默的系数,以及他上司的名字),编程找到能使幽默系数和最大的若干个人。
2019-09-15
[Golang]力扣Leetcode—中级算法—动态规划—跳跃游戏
题目:给定一个非负整数数组 nums ,你最初位于数组的 第一个下标 。数组中的每个元素代表你在该位置可以跳跃的最大长度。判断你是否能够到达最后一个下标。链接: 力扣Leetcode—中级算法—动态规划—跳跃游戏.示例 1:输入:nums = [2,3,1,1,4]输出:true解释:可以先跳 1 步,从下标 0 到达下标 1, 然后再从下标 1 跳 3 ...
2022-02-26
采用动态规划思维求解数塔问题,c++实现
采用动态规划思维求解数塔问题,c++实现数塔问题问题描述: 加粗样式从塔顶往下走,如何走过的步数最大问题分析:数塔游戏(5层)从塔顶到塔底,走过的值最大从第一层开始,往左走还是往右走,变化两个4层他的问题,因此改问题存在子问题重叠性质由于该问题要求走过的值最大,因此,该问题存在要求最优解,因此符合动态...
2022-10-31
经典动态规划:戳气球
今天我们要聊的这道题「Burst Balloon」和之前我们写过的那篇 经典动态规划:高楼扔鸡蛋问题 分析过的高楼扔鸡蛋问题类似,知名度很高,但难度确实也很大。因此 labuladong 公众号就给这道题赐个座,来看一看这道题目到底有多难。
2020-11-18
利用graphviz模块展示斐波那契数列的递归函数调用图(Python)
在博客动态规划法(一)从斐波那契数列谈起中,在求解斐波那契数列的第n项时,我们采用了递归方法和动态规划法来求解,当然递归方法的效率很差。本文将利用graphviz模块来展示斐波那契数列的递归函数调用图。 利用递归函数来求解斐波那契数列的第n项的Python代码如下:
2018-06-01
最大公共子串-蓝桥杯真题 动态规划(c++实现)
有两个字符串(可能包含空格),请找出其中最长的公共连续子串,输出其长度。比如“qwerff”和“fqwerfo”,最大公共子串为“qwerf”,长度是5。
2020-03-11
一道经典的动态规划入门题——leetcode64
显然这道题是满足动态规划的解题条件的每个路径的长度取决于之前路径的值求解最大路径的过程中需要多次用到之前求出的子路径的长度易得状态转移方程为
2022-07-31
leetcode讲解--877. Stone Game
Alex and Lee play a game with piles of stones. There are an even number of piles arranged in a row, and each pile has a positive integer number of stones piles[i].
2019-01-01
Interleaving String leetcode
Given s1, s2, s3, find whether s3 is formed by the interleaving of s1and s2. For example, Given: s1 = "aabcc", s2 = "dbbca", When s3 = "aadbbcbcac", return true. When s3 = "aadbbbaccc", returnfalse.
2016-01-13
[Leetcode] Maximum Subarray 子序列最大和
Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [−2,1,−3,4,−1,2,1,−5,4], the contiguous subarray [4,−1,2,1] has the largest sum = 6.
2015-08-23
记字节前端面试一道简单的算法题
记字节前端面试一道简单的算法题70. 爬楼梯 (medium)假设你正在爬楼梯。需要 n 阶你才能到达楼顶。每次你可以爬 1 或 2 个台阶。你有多少种不同的方法可以爬到楼顶呢?注意:给定 n 是一个正整数。示例 1:输入: 2输出: 2解释: 有两种方法可以爬到楼顶。1 阶 + 1 阶2 阶方法1.动态规划思路:因为每次可以爬 1 或 2 ...
2021-12-16