
动态规划算法
yuccess
这个作者很懒,什么都没留下…
展开
-
85. Maximal Rectangle
题目:Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area.For example, given the following matrix:1 0 1 0 01 0 1 1 11 1 1 1 1原创 2016-10-21 02:25:31 · 332 阅读 · 0 评论 -
Best Time to Buy and Sell Stock III -- LeetCode
原题链接: http://oj.leetcode.com/problems/best-time-to-buy-and-sell-stock-iii/ 为什么不能用 dp[i][j] = max(dp[i-1][j-1], dp[i-1][j] + diff) 参考:http://liangjiabin.com/blog/2015/04/leetcode-best-time-to-buy-a原创 2016-10-12 20:45:22 · 227 阅读 · 0 评论 -
44. Wildcard Matching -- LeetCode
题目:Implement wildcard pattern matching with support for '?' and '*'.'?' Matches any single character.'*' Matches any sequence of characters (including the empty sequence).The matching shoul原创 2016-10-19 23:22:38 · 327 阅读 · 0 评论 -
32. Longest Valid Parentheses -- leetcode
题目 Given a string containing just the characters’(’ and’)’, find the length of the longest valid (well-formed) parentheses substring. For “(()”, the longest valid parentheses substring is”()”, which原创 2016-10-19 20:38:19 · 277 阅读 · 0 评论 -
10. Regular Expression Matching
思路:dp[i][j] 表示s的前i个字符和p的前j个字符是否匹配。if s[0..i-1] matches p[0..j-1]如果 p[j - 1] != '*' 那么 dp[i][j] = dp[i - 1][j - 1] && (p[j - 1] == s[j - 1] || p[j - 1] == '.')如果 p[j - 1] == '*' 第一种情况:p[j - 2]重原创 2016-10-18 21:46:18 · 202 阅读 · 0 评论 -
120. Triangle
题目: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原创 2016-10-27 00:14:22 · 189 阅读 · 0 评论 -
115. 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 is formed from the original string by deleting some (c原创 2016-10-26 20:40:04 · 236 阅读 · 0 评论 -
97. Interleaving String ,leetcode
题目:Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.For example,Given:s1 = "aabcc",s2 = "dbbca",When s3 = "aadbbcbcac", return true.When s3 = "aadbbba原创 2016-10-26 18:49:03 · 242 阅读 · 0 评论 -
95. Unique Binary Search Trees II ,leetcode
题目:Given an integer n, generate all structurally unique BST's (binary search trees) that store values 1...n.For example,Given n = 3, your program should return all 5 unique BST's shown bel原创 2016-10-26 17:00:47 · 242 阅读 · 0 评论 -
96. Unique Binary Search Trees, leetcode
题目: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. 1 3 3 2原创 2016-10-26 02:20:02 · 229 阅读 · 0 评论 -
91. Decode Ways, leetcode
题目: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原创 2016-10-25 23:29:55 · 414 阅读 · 0 评论 -
87. 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 representation of s1 = "great": great / \原创 2016-10-25 19:43:58 · 417 阅读 · 0 评论 -
43. Multiply Strings 大数相乘 leetcode
题目:Given two numbers represented as strings, return multiplication of the numbers as a string.Note:The numbers can be arbitrarily large and are non-negative.Converting the input string原创 2016-10-25 18:20:53 · 246 阅读 · 0 评论 -
72. Edit Distance , LeetCode
题目:Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You have the following 3 operations permitted o原创 2016-10-20 23:55:45 · 227 阅读 · 0 评论 -
132. Palindrome Partitioning II, leetcode
题目:Given a string s, partition s such that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning of s.For example, given s = "aab"原创 2016-11-24 18:54:34 · 247 阅读 · 0 评论