
DP 动态规划
文章平均质量分 79
动态规划
河海哥yyds
正经人谁写代码吖!哦对了,我没说我是正经人。
展开
-
Java描述 LeetCode,剑指 Offer 13. 机器人的运动范围
DP原创 2022-02-21 15:28:22 · 172 阅读 · 0 评论 -
Java描述 LeetCode,剑指 Offer 66. 构建乘积数组
动态规划+一分为二的思想,将i左边单独算一块,i右边单独算一块原创 2022-02-03 11:30:54 · 199 阅读 · 0 评论 -
Java描述 LeetCode,剑指 Offer 47. 礼物的最大价值
一道比较常见的DP题,用滚动数组解决是最好的。原创 2022-02-02 10:06:40 · 217 阅读 · 0 评论 -
Java描述 LeetCode,435. Non-overlapping Intervals 不重复的间隔
大家好,我是河海哥,专注于后端,如果可以的话,想做一名code designer而不是普通的coder,一起见证河海哥的成长,您的评论与赞是我的最大动力,如有错误还请不吝赐教,万分感谢。一起支持原创吧!纯手打有笔误还望谅解。1-1:题目Given an array of intervals intervals where intervals[i] = [starti, endi], return the minimum number of intervals you need to remove t.原创 2021-12-07 22:28:31 · 603 阅读 · 0 评论 -
Java描述 LeetCode,45. Jump Game II 跳跃游戏II
1-1:题目Given an array of non-negative integers nums, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Your goal is to reach the last index in the minimum number of原创 2021-12-02 23:22:21 · 524 阅读 · 0 评论 -
Java描述 LeetCode,55. Jump Game 跳跃游戏
大家好,我是河海哥,专注于后端,如果可以的话,想做一名code designer而不是普通的coder,一起见证河海哥的成长,您的评论与赞是我的最大动力,如有错误还请不吝赐教,万分感谢。一起支持原创吧!1-1:题目You are given an integer array nums. You are initially positioned at the array’s first index, and each element in the array represents your maxim.原创 2021-11-30 19:37:42 · 3469 阅读 · 1 评论 -
Java描述 LeetCode,376. Wiggle Subsequence 摇摆序列
大家好,我是河海哥,专注于后端,如果可以的话,想做一名code designer而不是普通的coder,一起见证河海哥的成长,您的评论与赞是我的最大动力,如有错误还请不吝赐教,万分感谢。1-1:题目A wiggle sequence is a sequence where the differences between successive numbers strictly alternate between positive and negative. The first difference (.原创 2021-11-18 22:11:59 · 544 阅读 · 0 评论 -
Java描述 LeetCode,完全背包问题:先遍历背包还是先遍历物品 有什么讲究?,滚动数组的遍历顺序有什么讲究?
大家好,我是河海哥,专注于后端,如果可以的话,想做一名code designer而不是普通的coder,一起见证河海哥的成长,您的评论与赞是我的最大动力。1:完全背包之前偷懒,没有整理完全背包,以为很简单,但是做到完全背包的应用题的时候,发现了有的地方其实没有完全想明白,于是就整一个吧!这样回忆起来的时候,也有东西参照。1-1:题目有N件物品和⼀个最多能背重量为W的背包。第i件物品的重量是weight[i],得到的价值是value[i] 。每件物品都有⽆限个(也就是可以放⼊背包多次),求解将哪些.原创 2021-11-15 21:21:47 · 1239 阅读 · 1 评论 -
Java描述 LeetCode,516. Longest Palindromic Subsequence 最长回文子序列
大家好,我是河海哥,专注于后端,如果可以的话,想做一名code designer而不是普通的coder,一起见证河海哥的成长,您的评论与赞是我的最大动力,如有错误还请不吝赐教,万分感谢。1-1:题目Given a string s, find the longest palindromic subsequence’s length in s.A subsequence is a sequence that can be derived from another sequence by deleti.原创 2021-11-15 09:43:24 · 513 阅读 · 0 评论 -
Java描述 LeetCode,714. Best Time to Buy and Sell Stock with Transaction Fee
大家好,我是河海哥,专注于后端,如果可以的话,想做一名code designer而不是普通的coder,一起见证河海哥的成长,您的评论与赞是我的最大动力。1-1:题目You are given an array prices where prices[i] is the price of a given stock on the ith day, and an integer fee representing a transaction fee.Find the maximum profit yo.原创 2021-11-02 14:30:05 · 147 阅读 · 0 评论 -
Java描述 LeetCode,322. Coin Change
1-1:题目You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money.Return the fewest number of coins that you need to make up that amount. If that amount of money cannot be原创 2021-10-25 10:36:31 · 235 阅读 · 0 评论 -
Java描述 LeetCode,309. Best Time to Buy and Sell Stock with Cooldown
大家好,我是河海哥,专注于后端,如果可以的话,想做一名code designer而不是普通的coder,一起见证河海哥的成长,您的评论与赞是我的最大动力。1-1:题目You are given an array prices where prices[i] is the price of a given stock on the ith day.Find the maximum profit you can achieve. You may complete as many transaction.原创 2021-11-02 14:24:48 · 161 阅读 · 0 评论 -
leetcode:416. Partition Equal Subset Sum
leetcode:416. Partition Equal Subset Sum1-1:题目描述 problem descriptionGiven a non-empty array nums containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both subsets is equal.Example 1:原创 2021-10-20 19:41:13 · 148 阅读 · 0 评论 -
Java描述 LeetCode,518. Coin Change 2
题目描述:You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money.Return the number of combinations that make up that amount. If that amount of money cannot be made up by an原创 2021-10-24 20:35:40 · 1802 阅读 · 0 评论 -
Java描述 LeetCode,674. Longest Continuous Increasing Subsequence
大家好,我是河海哥,专注于后端,如果可以的话,想做一名code designer而不是普通的coder,一起见证河海哥的成长,您的评论与赞是我的最大动力。1-1:题目Given an unsorted array of integers nums, return the length of the longest continuous increasing subsequence (i.e. subarray). The subsequence must be strictly increasing.原创 2021-11-09 09:13:43 · 162 阅读 · 0 评论 -
Java描述 LeetCode,279. Perfect Squares
1-1:题目Given an integer n, return the least number of perfect square numbers that sum to n.A perfect square is an integer that is the square of an integer; in other words, it is the product of some integer with itself. For example, 1, 4, 9, and 16 are per原创 2021-10-26 09:15:20 · 213 阅读 · 0 评论 -
Java描述 LeetCode,647. Palindromic Substrings 回文子串
大家好,我是河海哥,专注于后端,如果可以的话,想做一名code designer而不是普通的coder,一起见证河海哥的成长,您的评论与赞是我的最大动力。1-1:题目Given a string s, return the number of palindromic substrings in it.A string is a palindrome when it reads the same backward as forward.A substring is a contiguous seq.原创 2021-11-14 16:25:20 · 530 阅读 · 0 评论 -
Java描述 LeetCode,300. Longest Increasing Subsequence,并且输出最小的
大家好,我是河海哥,专注于后端,如果可以的话,想做一名code designer而不是普通的coder,一起见证河海哥的成长,您的评论与赞是我的最大动力。1-1:题目Given an integer array nums, return the length of the longest strictly increasing subsequence.A subsequence is a sequence that can be derived from an array by deleting .原创 2021-11-08 10:43:50 · 225 阅读 · 0 评论 -
Java描述 LeetCode,121. Best Time to Buy and Sell Stock(买卖股票的时机I)
1-1:题目You are given an array prices where prices[i] is the price of a given stock on the ith day.You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock.Return the maximum原创 2021-10-29 15:31:32 · 175 阅读 · 0 评论 -
Java描述 LeetCode,718. Maximum Length of Repeated Subarray
大家好,我是河海哥,专注于后端,如果可以的话,想做一名code designer而不是普通的coder,一起见证河海哥的成长,您的评论与赞是我的最大动力。1-1:题目Given two integer arrays nums1 and nums2, return the maximum length of a subarray that appears in both arrays.Example 1:Input: nums1 = [1,2,3,2,1], nums2 = [3,2,1,4,7].原创 2021-11-09 10:38:24 · 163 阅读 · 0 评论 -
leetcode:0-1背包问题
力扣0-1背包问题1-1: 问题描述有N件物品和⼀个最多能被重量为W 的背包。第i件物品的重量是weight[i],得到的价值是value[i] 。每件物品只能⽤⼀次,求解将哪些物品装⼊背包⾥物品价值总和最⼤。有点抽象,换一个具体的场景来描述:题目描述:总重量 total weight7,共有4个物品,分别是:weightvalue11344557问怎么才能使得背包的总value最大,每个物品只能放一次。 不知道大家是否想过为什么叫0-1背包呢,原创 2021-10-20 18:49:47 · 3802 阅读 · 0 评论 -
Java描述 LeetCode,494. Target Sum
LeetCode,494. Target Sum1-1:题目描述You are given an integer array nums and an integer target.You want to build an expression out of nums by adding one of the symbols '+' and '-' before each integer in nums and then concatenate all the integers.For examp原创 2021-10-22 09:11:57 · 227 阅读 · 0 评论 -
Java描述 LeetCode,123. Best Time to Buy and Sell Stock III(买卖股票的时机III)
大家好,我是河海哥,专注于后端,如果可以的话,想做一名code designer而不是普通的coder,一起见证河海哥的成长,您的评论与赞是我的最大动力。1-1:题目You are given an array prices where prices[i] is the price of a given stock on the ith day.Find the maximum profit you can achieve. You may complete at most two transac.原创 2021-10-31 11:28:22 · 161 阅读 · 0 评论 -
Java描述 LeetCode,123. Best Time to Buy and Sell Stock IV(买卖股票的时机IV)
大家好,我是河海哥,专注于后端,如果可以的话,想做一名code designer而不是普通的coder,一起见证河海哥的成长,您的评论与赞是我的最大动力。1-1:题目You are given an integer array prices where prices[i] is the price of a given stock on the ith day, and an integer k.Find the maximum profit you can achieve. You may co.原创 2021-10-31 14:06:36 · 115 阅读 · 0 评论 -
Java描述 LeetCode,139. Word Break
题目Given a string s and a dictionary of strings wordDict, return true if s can be segmented into a space-separated sequence of one or more dictionary words.Note that the same word in the dictionary may be reused multiple times in the segmentation.Example原创 2021-10-26 11:01:59 · 171 阅读 · 0 评论 -
Java描述 LeetCode,474. Ones and Zeroes
1-1:题目描述:You are given an array of binary strings strs and two integers m and n.Return the size of the largest subset of strs such that there are at most m 0's and n 1's in the subset.A set x is a subset of a set y if all elements of x are also elements原创 2021-10-22 21:13:29 · 172 阅读 · 0 评论 -
Java描述 LeetCode,213. House Robber II
大家好,我是河海哥,专注于后端,如果可以的话,想做一名code designer而不是普通的coder,一起见证河海哥的成长,您的评论与赞是我的最大动力。1-1:题目You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at this place are arranged in a circle..原创 2021-10-28 10:21:00 · 151 阅读 · 0 评论 -
Java描述 LeetCode,122. Best Time to Buy and Sell Stock II(买卖股票的时机II)
1-1:题目You are given an integer array prices where prices[i] is the price of a given stock on the ith day.On each day, you may decide to buy and/or sell the stock. You can only hold at most one share of the stock at any time. However, you can buy it then原创 2021-10-29 17:15:03 · 185 阅读 · 0 评论 -
Java描述 LeetCode,53. Maximum Subarray,最大连续子数组之和
动态规划,贪心算法,分治,三种方法解决问题原创 2021-11-11 10:03:49 · 511 阅读 · 0 评论 -
Java描述 LeetCode,377. Combination Sum IV
题目Given an array of distinct integers nums and a target integer target, return the number of possible combinations that add up to target.The answer is guaranteed to fit in a 32-bit integer.Example 1:Input: nums = [1,2,3], target = 4Output: 7Explanati原创 2021-10-25 09:14:44 · 182 阅读 · 0 评论 -
Java描述 LeetCode,392. Is Subsequence
大家好,我是河海哥,专注于后端,如果可以的话,想做一名code designer而不是普通的coder,一起见证河海哥的成长,您的评论与赞是我的最大动力。1-1:题目Given two strings s and t, return true if s is a subsequence of t, or false otherwise.A subsequence of a string is a new string that is formed from the original string .原创 2021-11-12 20:36:39 · 627 阅读 · 2 评论 -
Java描述 LeetCode,115. Distinct Subsequences
大家好,我是河海哥,专注于后端,如果可以的话,想做一名code designer而不是普通的coder,一起见证河海哥的成长,您的评论与赞是我的最大动力。1-1:题目:Given two strings s and t, return the number of distinct subsequences of s which equals t.A string’s subsequence is a new string formed from the original string by del.原创 2021-11-13 11:15:48 · 302 阅读 · 0 评论 -
Java描述 LeetCode,1143. Longest Common Subsequence
1-1:题目Given two strings text1 and text2, return the length of their longest common subsequence. If there is no common subsequence, return 0.A subsequence of a string is a new string generated from the original string with some characters (can be none) de原创 2021-11-10 21:58:15 · 384 阅读 · 0 评论 -
Java描述 LeetCode,72. Edit Distance
大家好,我是河海哥,专注于后端,如果可以的话,想做一名code designer而不是普通的coder,一起见证河海哥的成长,您的评论与赞是我的最大动力。1-1:题目Given two strings word1 and word2, return the minimum number of operations required to convert word1 to word2.You have the following three operations permitted on a wor.原创 2021-11-14 10:46:57 · 497 阅读 · 0 评论 -
Java描述 LeetCode,1035. Uncrossed Lines
1-1:题目You are given two integer arrays nums1 and nums2. We write the integers of nums1 and nums2 (in the order they are given) on two separate horizontal lines.We may draw connecting lines: a straight line connecting two numbers nums1[i] and nums2[j] suc原创 2021-11-11 09:13:45 · 317 阅读 · 0 评论 -
Java描述 LeetCode,198. House Robber
大家好,我是河海哥,专注于后端,如果可以的话,想做一名code designer而不是普通的coder,一起见证河海哥的成长,您的评论与赞是我的最大动力。1-1:题目You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each.原创 2021-10-28 08:43:22 · 168 阅读 · 0 评论 -
Java描述 LeetCode,多重背包问题与二进制优化
1-1:题目有N种物品和⼀个容量为V 的背包。第i种物品最多有sums[i]件可⽤,每件耗费的空间是weight[i] ,价值是value[i] 。求解将哪些物品装⼊背包可使这些物品的耗费的空间 总和不超过背包容量,且价值总和最⼤。1-2:idea前提:你得熟知0-1背包问题的解法。多重背包和0-1背包的典型区分,在于,0-1背包物品只有一个,而多重背包有物品有多个,记录在一个数组中。解决思路,主要围绕着,将多重背包问题转换成0-1背包问题,对于0-1背包问题。思路1:我们可以选择0个或者1个原创 2021-10-27 14:48:53 · 445 阅读 · 0 评论 -
Java描述 LeetCode,583. Delete Operation for Two Strings
大家好,我是河海哥,专注于后端,如果可以的话,想做一名code designer而不是普通的coder,一起见证河海哥的成长,您的评论与赞是我的最大动力。1-1:题目Given two strings word1 and word2, return the minimum number of steps required to make word1 and word2 the same.In one step, you can delete exactly one character in eit.原创 2021-11-13 14:24:30 · 804 阅读 · 0 评论