![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
动态规划
文章平均质量分 71
小榕流光
这个作者很懒,什么都没留下…
展开
-
[leetcode] 376. Wiggle Subsequence 解题报告
题目链接: https://leetcode.com/problems/wiggle-subsequence/A sequence of numbers is called a wiggle sequence if the differences between successive numbers strictly alternate between positive and neg原创 2016-07-22 05:50:45 · 4313 阅读 · 2 评论 -
[leetcode] 377. Combination Sum IV 解题报告
题目链接: https://leetcode.com/problems/combination-sum-iv/Given an integer array with all positive numbers and no duplicates, find the number of possible combinations that add up to a positive inte原创 2016-07-29 14:08:17 · 6250 阅读 · 0 评论 -
[leetcode] 256. Paint House 解题报告
题目链接:https://leetcode.com/problems/paint-house/There are a row of n houses, each house can be painted with one of the three colors: red, blue or green. The cost of painting each house with a cer原创 2016-03-13 03:03:02 · 4034 阅读 · 0 评论 -
[leetcode] 152. Maximum Product Subarray 解题报告
题目链接:https://leetcode.com/problems/maximum-product-subarray/Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the原创 2015-12-22 15:20:44 · 610 阅读 · 0 评论 -
[leetcode] 213. House Robber II 解题报告
题目链接:https://leetcode.com/problems/house-robber-ii/Note: This is an extension of House Robber.After robbing those houses on that street, the thief has found himself a new place for his thiev原创 2015-12-23 14:21:40 · 578 阅读 · 0 评论 -
[leetcode] 135. Candy 解题报告
题目链接: https://leetcode.com/problems/candy/There are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following r原创 2016-05-06 14:05:34 · 1336 阅读 · 0 评论 -
[leetcode] 91. Decode Ways 解题报告
题目链接:https://leetcode.com/problems/decode-ways/A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an enco原创 2015-11-30 12:21:30 · 659 阅读 · 0 评论 -
[leetcode] 97. Interleaving String 解题报告
题目链接:https://leetcode.com/problems/interleaving-string/Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.For example,Given:s1 = "aabcc",s2 = "dbbca",When原创 2015-11-29 14:50:51 · 569 阅读 · 0 评论 -
[leetcode] 357. Count Numbers with Unique Digits 解题报告
题目链接:https://leetcode.com/problems/count-numbers-with-unique-digits/Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x n.Example:Given n = 2, return 91. (原创 2016-06-13 12:34:24 · 5429 阅读 · 0 评论 -
[leetcode] 45. Jump Game II 解题报告
题目链接:https://leetcode.com/problems/jump-game-ii/Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents you原创 2015-10-28 13:44:09 · 743 阅读 · 0 评论 -
[leetcode] 62. Unique Paths 解题报告
题目链接:https://leetcode.com/problems/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 a原创 2015-11-04 15:25:29 · 488 阅读 · 0 评论 -
[leetcode] 322. Coin Change 解题报告
题目链接:https://leetcode.com/problems/coin-change/You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you原创 2016-02-20 04:32:28 · 1086 阅读 · 0 评论 -
[leetcode] 279. Perfect Squares 解题报告
题目链接:https://leetcode.com/problems/perfect-squares/Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n.For example, g原创 2015-12-24 14:14:58 · 1995 阅读 · 0 评论 -
[leetcode] 139. Word Break 解题报告
题目链接:https://leetcode.com/problems/word-break/Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.原创 2015-10-31 13:54:22 · 1201 阅读 · 0 评论 -
[leetcode] 221. Maximal Square 解题报告
题目链接:https://leetcode.com/problems/maximal-square/Given a 2D binary matrix filled with 0's and 1's, find the largest square containing all 1's and return its area.For example, given the foll原创 2015-12-16 14:20:04 · 655 阅读 · 0 评论 -
[leetcode] 64. Minimum Path Sum 解题报告
题目链接:https://leetcode.com/problems/minimum-path-sum/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 it原创 2015-11-30 13:41:49 · 410 阅读 · 0 评论 -
[leetcode] 63. Unique Paths II 解题报告
题目链接:https://leetcode.com/problems/unique-paths-ii/Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle an原创 2015-11-04 15:49:36 · 585 阅读 · 0 评论 -
[leetcode] 32. Longest Valid Parentheses 解题报告
题目链接:https://leetcode.com/problems/longest-valid-parentheses/Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring原创 2015-12-23 14:58:45 · 679 阅读 · 0 评论 -
[leetcode] 121. Best Time to Buy and Sell Stock 解题报告
题目链接: https://leetcode.com/problems/best-time-to-buy-and-sell-stock/Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to compl原创 2016-05-19 08:42:35 · 613 阅读 · 0 评论 -
[leetcode] 416. Partition Equal Subset Sum 解题报告
题目链接:https://leetcode.com/problems/partition-equal-subset-sum/Given a non-empty array containing only positive integers, find if the array can be partitioned into two subsets such that the sum o原创 2016-10-10 04:43:26 · 6612 阅读 · 0 评论 -
[leetcode] 115. Distinct Subsequences 解题报告
题目链接:https://leetcode.com/problems/distinct-subsequences/Given a string S and a string T, count the number of distinct subsequences of T in S.A subsequence of a string is a new string which原创 2015-11-30 10:12:37 · 641 阅读 · 0 评论 -
[leetcode] 375. Guess Number Higher or Lower II 解题报告
题目链接: https://leetcode.com/problems/guess-number-higher-or-lower-ii/We are playing the Guess Game. The game is as follows:I pick a number from 1 to n. You have to guess which number I pi原创 2016-07-22 08:03:14 · 4340 阅读 · 0 评论 -
[leetcode] 312. Burst Balloons 解题报告
题目链接:https://leetcode.com/problems/burst-balloons/Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by array nums. You are asked to burst all t原创 2016-05-13 15:35:07 · 4325 阅读 · 0 评论 -
[leetcode] 123. Best Time to Buy and Sell Stock III 解题报告
题目链接:https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iii/Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the原创 2016-06-11 03:40:07 · 770 阅读 · 0 评论 -
[leetcode] 188. Best Time to Buy and Sell Stock IV 解题报告
题目链接:https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iv/Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the m原创 2016-06-15 04:26:23 · 3265 阅读 · 0 评论 -
[leetcode] 276. Paint Fence 解题报告
题目链接:https://leetcode.com/problems/paint-fence/There is a fence with n posts, each post can be painted with one of the k colors.You have to paint all the posts such that no more than two adj...原创 2016-03-12 05:44:37 · 5628 阅读 · 0 评论 -
[leetcode] 96. Unique Binary Search Trees 解题报告
题目链接:https://leetcode.com/problems/unique-binary-search-trees/Given n, how many structurally unique BST's (binary search trees) that store values 1...n?For example,Given n = 3, there are a原创 2015-11-04 14:23:05 · 590 阅读 · 0 评论 -
[leetcode] 55. Jump Game 解题报告
题目链接:https://leetcode.com/problems/jump-game/Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your max原创 2015-10-28 12:58:35 · 662 阅读 · 0 评论 -
[leetcode] 174. Dungeon Game 解题报告
题目链接:https://leetcode.com/problems/dungeon-game/The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out原创 2016-05-13 07:55:07 · 3514 阅读 · 1 评论 -
[leetcode] 300. Longest Increasing Subsequence 解题报告
题目链接:https://leetcode.com/problems/longest-increasing-subsequence/Given an unsorted array of integers, find the length of longest increasing subsequence.For example,Given [10, 9, 2, 5, 3,原创 2015-12-23 10:52:37 · 1020 阅读 · 0 评论 -
[leetcode] 334. Increasing Triplet Subsequence 解题报告
题目链接:https://leetcode.com/problems/increasing-triplet-subsequence/Given an unsorted array return whether an increasing subsequence of length 3 exists or not in the array.Formally the functio原创 2016-02-19 13:14:48 · 1824 阅读 · 0 评论 -
[leetcode] 265. Paint House II 解题报告
题目链接:https://leetcode.com/problems/paint-house-ii/here are a row of n houses, each house can be painted with one of the k colors. The cost of painting each house with a certain color is differen原创 2016-03-05 12:50:21 · 3435 阅读 · 0 评论 -
[leetcode] 198. House Robber 解题报告
题目链接:https://leetcode.com/problems/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 constraint stoppin原创 2015-12-23 11:42:35 · 531 阅读 · 0 评论 -
[leetcode] 303. Range Sum Query - Immutable 解题报告
题目链接:https://leetcode.com/problems/range-sum-query-immutable/Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.Example:Given nums = [-2原创 2015-12-22 05:02:04 · 491 阅读 · 0 评论 -
[leetcode] 70. Climbing Stairs 解题报告
题目链接:https://leetcode.com/problems/climbing-stairs/You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways原创 2015-12-22 05:24:27 · 484 阅读 · 0 评论 -
[leetcode] 53. Maximum Subarray 解题报告
题目链接:https://leetcode.com/problems/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原创 2015-12-16 08:53:18 · 545 阅读 · 0 评论 -
[leetcode] 368. Largest Divisible Subset 解题报告
题目链接: https://leetcode.com/problems/largest-divisible-subset/Given a set of distinct positive integers, find the largest subset such that every pair (Si, Sj) of elements in this subset satisfi原创 2016-06-27 12:30:26 · 10504 阅读 · 0 评论 -
[leetcode] 309. Best Time to Buy and Sell Stock with Cooldown 解题报告
题目链接:https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-cooldown/ Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to fi...原创 2016-06-14 14:53:30 · 4583 阅读 · 0 评论 -
[leetcode] 132. Palindrome Partitioning II 解题报告
题目链接: https://leetcode.com/problems/palindrome-partitioning-ii/Given a string s, partition s such that every substring of the partition is a palindrome.Return the minimum cuts needed for a p原创 2015-12-13 12:13:51 · 958 阅读 · 0 评论 -
[leetcode] 87. Scramble String 解题报告
题目链接:https://leetcode.com/problems/scramble-string/Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible re原创 2015-11-23 14:19:28 · 620 阅读 · 0 评论