![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
LeetCode-动态规划
文章平均质量分 52
Euadvancer
代码才是真爱
展开
-
376. Wiggle Subsequence -Medium
Question A sequence of numbers is called a wiggle sequence if the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be原创 2017-02-04 19:38:45 · 338 阅读 · 0 评论 -
62. Unique Paths -Medium
Question 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 t原创 2017-02-12 17:30:04 · 366 阅读 · 0 评论 -
63. Unique Paths II -Medium
Question *Follow up for “Unique Paths”: Now consider if some obstacles are added to the grids. How many unique paths would there be? An obstacle and empty space is marked as 1 and 0 respect原创 2017-02-12 20:37:14 · 269 阅读 · 0 评论 -
53. Maximum Subarray -Easy
Question Find the contiguous subarray within an array (containing at least one number) which has the largest sum. 找到一个元素总和最大的连续子数组(包含至少一个数字)Example For example, given the array [-2,1,-3,4,-1,原创 2017-02-12 20:56:32 · 281 阅读 · 0 评论 -
494. Target Sum -Medium
Question You are given a list of non-negative integers, a1, a2, …, an, and a target, S. Now you have 2 symbols + and -. For each integer, you should choose one from + and - as its new symbol. Fi原创 2017-02-13 14:37:00 · 412 阅读 · 0 评论 -
486. Predict the Winner -Medium
Question Given an array of scores that are non-negative integers. Player 1 picks one of the numbers from either end of the array followed by the player 2 and then player 1 and so on. Each time a play原创 2017-02-13 15:55:59 · 293 阅读 · 0 评论 -
474. Ones and Zeroes -Medium
Question In the computer world, use restricted resource you have to generate maximum benefit is what we always want to pursue. For now, suppose you are a dominator of m 0s and n 1s respectively.原创 2017-02-13 17:17:51 · 375 阅读 · 0 评论 -
467. Unique Substrings in Wraparound String -Medium
Question Consider the string s to be the infinite wraparound string of “abcdefghijklmnopqrstuvwxyz”, so s will look like this: “…zabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd….”. Now原创 2017-02-13 21:25:40 · 301 阅读 · 0 评论 -
464. Can I Win -Medium
Question In the “100 game,” two players take turns adding, to a running total, any integer from 1..10. The player who first causes the running total to reach or exceed 100 wins. What if we chang原创 2017-02-13 22:07:01 · 514 阅读 · 0 评论 -
303. Range Sum Query - Immutable -Medium
Question Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive. Note: 1. You may assume that the array does not change. 2. There are many cal原创 2017-02-14 11:18:01 · 229 阅读 · 0 评论 -
121. Best Time to Buy and Sell Stock -Easy
Question 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 complete at most one transaction (ie, buy one and sell one share of原创 2017-02-14 20:17:27 · 248 阅读 · 0 评论 -
96. Unique Binary Search Trees -Medium
Question Given n, how many structurally unique BST’s (binary search trees) that store values 1…n? 给出n,可以组成多少个不重复的BST(二叉查找树),其中每个结点的值为1…nExample Given n = 3, there are a total of 5 unique BST’原创 2017-02-12 11:39:54 · 247 阅读 · 0 评论 -
70. Climbing Stairs -Easy
Question 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 can you climb to the top? Note: Given n原创 2017-02-14 21:09:23 · 301 阅读 · 0 评论 -
17. Letter Combinations of a Phone Number -Medium
Question Given a digit string, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telephone buttons) is given below.原创 2017-02-23 20:40:26 · 579 阅读 · 0 评论 -
416. Partition Equal Subset Sum -Medium
Question Given a non-empty array 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. Note: Each of原创 2017-02-01 21:49:04 · 420 阅读 · 0 评论 -
413. Arithmetic Slices -Medium
Question A sequence of number is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same. For example, these are arithm原创 2017-02-02 20:25:32 · 354 阅读 · 0 评论 -
392. Is Subsequence -Medium
Question Given a string s and a string t, check if s is subsequence of t. You may assume that there is only lower case English letters in both s and t. t is potentially a very long (length ~= 50原创 2017-02-03 19:33:48 · 387 阅读 · 0 评论 -
64. Minimum Path Sum -Medium
Question 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原创 2017-02-12 17:00:17 · 437 阅读 · 0 评论 -
91. Decode Ways -Medium
Question A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26 Given an encoded message containing digits, determine the to原创 2017-02-12 15:43:55 · 366 阅读 · 0 评论 -
95. Unique Binary Search Trees II -Meidum
Question Given an integer n, generate all structurally unique BST’s (binary search trees) that store values 1…n. 给出一个整数n,请你生成所有的不重复的BST的结构(即构建树),它的结点值为1…nExample Given n = 3, your program sho原创 2017-02-12 14:18:39 · 252 阅读 · 0 评论 -
375. Guess Number Higher or Lower II -Medium
Question 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 picked. Every time you guess wrong, I’ll tell you whether the n原创 2017-02-05 15:37:21 · 365 阅读 · 0 评论 -
300. Longest Increasing Subsequence -Medium
Question Given an unsorted array of integers, find the length of longest increasing subsequence. Your algorithm should run in O(n2) complexity. 给出一个未排序的整数数组,找出最长增长子序列的长度(算法时间复杂度应该是O(N ^ 2))原创 2017-02-05 21:00:44 · 261 阅读 · 0 评论 -
368. Largest Divisible Subset -Medium
Question Given a set of distinct positive integers, find the largest subset such that every pair (Si, Sj) of elements in this subset satisfies: Si % Sj = 0 or Sj % Si = 0. If there are multiple原创 2017-02-05 21:26:12 · 275 阅读 · 0 评论 -
357. Count Numbers with Unique Digits -Medium
Question Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. 给出一个非负整数n,在 0 <= x <10 ^n 的范围内,统计每一位都不重复的数字的个数Example Given n = 2, return 91. (The answer原创 2017-02-06 13:40:37 · 336 阅读 · 0 评论 -
343. Integer Break -Medium
Question Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get. Note: You may ass原创 2017-02-06 14:48:44 · 371 阅读 · 0 评论 -
338. Counting Bits -Medium
Question Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1’s in their binary representation and return them as an array. 给出一个非负整数num原创 2017-02-06 19:27:43 · 234 阅读 · 0 评论 -
322. Coin Change -Medium
Question 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 need to make up that amount. If that amount原创 2017-02-06 20:14:06 · 309 阅读 · 0 评论 -
279. Perfect Squares -Medium
Question Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, …) which sum to n. 给出一个正整数n,找到相加得到n的最少个数的完全平方数字(比如1, 4, 9, 16)Example For examp原创 2017-02-08 11:14:11 · 482 阅读 · 0 评论 -
264. Ugly Number II -Medium
Question Write a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 is the sequence of原创 2017-02-08 13:26:09 · 324 阅读 · 0 评论 -
309. Best Time to Buy and Sell Stock with Cooldown -Medium
Question 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 maximum profit. You may complete as many transactions as you like原创 2017-02-08 22:13:17 · 257 阅读 · 0 评论 -
304. Range Sum Query 2D - Immutable -Medium
Question 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, col2). The above rectangle原创 2017-02-11 11:46:14 · 243 阅读 · 0 评论 -
221. Maximal Square -Medium
Question Given a 2D binary matrix filled with 0’s and 1’s, find the largest square containing only 1’s and return its area. 给出一个二维矩阵,元素由0,1组成,找到最大的仅由1组成的正方形,返回其面积大小Example given the following原创 2017-02-11 15:38:53 · 308 阅读 · 0 评论 -
198. House Robber -Easy
Question 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 of them is that adja原创 2017-02-11 17:17:34 · 244 阅读 · 0 评论 -
213. House Robber II -Medium
Question 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 thievery so that he will not get too much attentio原创 2017-02-11 17:29:55 · 321 阅读 · 0 评论 -
152. Maximum Product Subarray -Medium
Question Find the contiguous subarray within an array (containing at least one number) which has the largest product. 找到一个元素的乘积最大的连续子数组(包含至少一个元素)Example For example, given the array [2,3,-2,4原创 2017-02-11 20:33:08 · 276 阅读 · 0 评论 -
139. Word Break -Medium
Question Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words. Yo原创 2017-02-11 22:23:51 · 362 阅读 · 0 评论 -
120. Triangle -Medium
Question Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. 给出一个三角形,找出从其顶端到底端的最小路径的总和,每次移动是下一行的相邻数字。Example given the原创 2017-02-12 10:44:58 · 219 阅读 · 0 评论 -
377. Combination Sum IV -Medium
Question 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. 给出一个全为正整数且无重复数字的数组,找出加起来是一个正整数目标值的原创 2017-02-04 11:07:43 · 376 阅读 · 0 评论