leetcode之dynamic programming
Shawn_Redemption
这个作者很懒,什么都没留下…
展开
-
【Leetcode】Jump Game II (DP)
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 maximum jump length at that position.Your goal i原创 2014-11-10 09:26:48 · 312 阅读 · 0 评论 -
【Leetcode】Regular Expression Matching (DP)
Implement regular expression matching with support for '.' and '*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.The matching should cover the entire input st原创 2014-11-02 02:17:28 · 422 阅读 · 0 评论 -
【Leetcode】Best Time to Buy and Sell Stock (DP)
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 the stock),原创 2014-11-03 06:29:15 · 283 阅读 · 0 评论 -
【Leetcode】Maximum Subarray (DP)
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]原创 2014-11-05 11:27:09 · 297 阅读 · 0 评论 -
【Leetcode】Maximum Product Subarray (DP)
Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array [2,3,-2,4],the contiguous subarray [2,3] has the larges原创 2014-11-05 12:33:37 · 444 阅读 · 0 评论 -
【Leetcode】Unique Binary Search Trees (DP)
Given n, how many structurally unique BST's (binary search trees) that store values 1...n?For example,Given n = 3, there are a total of 5 unique BST's.ka'te'lan'shu原创 2014-11-02 02:45:43 · 314 阅读 · 0 评论 -
【Leetcode】Climbing Stairs (DP)
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?1原创 2014-11-02 02:25:43 · 340 阅读 · 0 评论 -
【Leetcode】Maximal Rectangle (DP)
Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.原创 2014-10-31 12:17:25 · 439 阅读 · 0 评论 -
【Leetcode】Best Time to Buy and Sell Stock III (DP)
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 at most two transactions.Note:You ma原创 2014-11-04 07:56:26 · 518 阅读 · 2 评论 -
【Leetcode】Unique Paths II (DP)
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 respectively in the原创 2014-11-02 03:53:49 · 268 阅读 · 0 评论 -
【Leetcode】Unique Paths (DP)
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原创 2014-11-02 03:18:25 · 294 阅读 · 0 评论 -
【Leetcode】Minimum Path Sum (DP)
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 or right at原创 2014-11-02 04:19:05 · 346 阅读 · 0 评论 -
【Leetcode】Word Break (DP)
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.For example, givens = "leetcode",dict = ["leet"原创 2014-11-13 03:53:23 · 321 阅读 · 0 评论 -
【Leetcode】Decode Ways (DP)
A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message containing digits, determine the total numb原创 2014-11-12 12:22:43 · 524 阅读 · 0 评论 -
【Leetcode】Triangle (DP)
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2], [3,4], [原创 2014-11-11 07:19:51 · 368 阅读 · 0 评论 -
【Leetcode】Jump Game (DP)
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 maximum jump length at that position.Determine i原创 2014-11-10 05:27:31 · 354 阅读 · 0 评论 -
【Leetcode】Unique Binary Search Tree II (DP)
public ArrayList generateTrees(int n) { return helper(1, n); } private ArrayList helper(int left, int right) { ArrayList result = new ArrayList(); if (left > right) { result.add(null);原创 2014-11-08 01:17:36 · 286 阅读 · 0 评论