![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
LeetCode DP
文章平均质量分 75
Spencer_Lin
If you fight for your dream, one day....
展开
-
Unique Paths Java
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-08-19 13:50:47 · 695 阅读 · 0 评论 -
Longest Palindromic Substring Java
Idea: Nested loop: Outer loop: i start from back to front inner loop: j start from i to the endStated more formally below:Define P[i][j] ← true iffthe substring Si … Sj is a palindrome原创 2014-09-15 16:22:03 · 349 阅读 · 0 评论 -
Word Break II Java
Two Approach: NP-problem Solution#1: brute force of Recursive-loop, The appraoch is pretty similar with N-Queens problem Maintain a result List, traverse all the sub-String list Ca原创 2014-09-15 17:40:24 · 492 阅读 · 0 评论 -
Palindrome Partitioning Java
Idea: Recursive-loop + dynamic programming + backtracking Combination of Longest Palindromic Substring & Word Break II There are two major steps: 1.palindromic dictionary that using sam原创 2014-09-17 14:15:10 · 305 阅读 · 0 评论 -
Unique Paths II Java
public class Solution { public int uniquePathsWithObstacles(int[][] obstacleGrid) { int rows=obstacleGrid.length; int cols=obstacleGrid[0].length; //check for special case原创 2014-09-13 10:44:22 · 336 阅读 · 0 评论 -
Best Time to Buy and Sell Stock II Java
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 (ie, buy on原创 2014-08-27 10:38:55 · 306 阅读 · 0 评论 -
Best Time to Buy and Sell Stock Java
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-08-27 10:19:20 · 326 阅读 · 0 评论 -
Best Time to Buy and Sell Stock III Java
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 may no原创 2014-08-27 10:57:19 · 378 阅读 · 0 评论 -
Word Break LeetCode Java
Idea: Dynamic programming + Nested Loop outer loop: i start from 0 to N inner loop: j start from 0 to i Use a boolean array in size of N to record the previous info res[i+1] pu原创 2014-09-15 17:42:20 · 435 阅读 · 0 评论 -
Jump Game II Java
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-08-22 09:39:09 · 378 阅读 · 0 评论 -
Maximum Subarray Java
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] ha原创 2014-08-22 09:01:31 · 436 阅读 · 0 评论 -
Jump Game Java
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-08-22 09:16:05 · 369 阅读 · 0 评论 -
Minimum Path Sum Java
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-08-19 14:49:45 · 305 阅读 · 0 评论 -
Palindrome Partitioning II Java
public static int minCut(String s) { if(s==null || s.length()==0) return -1; int len=s.length(); boolean[][] dict=palinDict(s); int[] res=new int[len+1]; res[0]原创 2014-09-17 14:38:38 · 404 阅读 · 0 评论