随笔分类 - 数据结构--动态规划
摘要:课程中, 作者将DP的问题分成以下几类: 1. 0/1 Knapsack, 0/1背包,6个题 0/1 Knapsack,0/1背包问题 Equal Subset Sum Partition,相等子集划分问题 Subset Sum,子集和问题 Minimum Subset Sum Differenc
阅读全文
摘要:Given an integer array with all positive numbers and no duplicates, find the number of possible combinations that add up to a positive integer target.
阅读全文
摘要:Given a 2D matrix matrix, find the sum of the elements inside the rectangle defined by its upper left corner (row1, col1) and lower right corner (row2
阅读全文
摘要:Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive. Example: Given nums = [-2, 0, 3, -5, 2, -1] sumR
阅读全文
摘要:Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n. Example 1: Input: n = 12 O
阅读全文
摘要:Given a 2D binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area. Example: Input: 1 0 1 0 0 1 0 1 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 ar
阅读全文
摘要:Given an integer array nums, find the contiguous subarray within an array (containing at least one number) which has the largest product. Example 1: I
阅读全文
摘要:198. House Robber You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only cons
阅读全文
摘要:Given an unsorted array of integers, find the length of longest increasing subsequence. For example,Given [10, 9, 2, 5, 3, 7, 101, 18],The longest inc
阅读全文
摘要:字符串子序列 300. Longest Increasing Subsequence(LIS最长递增子序列 动态规划) 输入:nums = [10,9,2,5,3,7,101,18] 输出:4 解释:最长递增子序列是 [2,3,7,101],因此长度为 4 。 dp[i] 表示以 nums[i] 这
阅读全文