DP
文章平均质量分 79
cgdong2014
这个作者很懒,什么都没留下…
展开
-
Edit Distance
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 on a word:原创 2014-12-22 08:07:27 · 245 阅读 · 0 评论 -
KMP
与传统的字符串匹配(BF算法)相比,ji原创 2014-10-16 13:48:30 · 207 阅读 · 0 评论 -
Different Ways to Add Parentheses
Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. The valid operators are +,- and *. Example 1 Inp原创 2015-08-03 11:45:32 · 242 阅读 · 0 评论 -
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. For example, given s = "leetcode", dict = ["leet"原创 2014-09-22 02:41:11 · 218 阅读 · 0 评论 -
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 your maximum jump length at that position. Your goal i原创 2014-12-13 04:19:25 · 219 阅读 · 0 评论 -
Word Search
Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically n原创 2015-01-05 10:25:08 · 245 阅读 · 0 评论 -
Maximal Rectangle
Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area. 思路: First, we storage the width of every原创 2014-10-16 08:25:41 · 230 阅读 · 0 评论 -
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 and empty space is marked as 1 and 0 respectively in the原创 2014-11-18 04:55:43 · 182 阅读 · 0 评论 -
Word Break II
Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word. Return all such possible sentences. For example, given s = "原创 2014-09-22 03:56:14 · 494 阅读 · 0 评论 -
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 (can be none)原创 2014-09-28 10:59:16 · 290 阅读 · 0 评论 -
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 palindrome partitioning of s. For example, given s = "aab", Return 1 s原创 2014-09-22 11:44:19 · 275 阅读 · 0 评论 -
Decode Ways
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 total numb原创 2015-01-05 14:30:20 · 261 阅读 · 0 评论 -
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 its path. Note: You can only move either down or right at原创 2014-12-22 08:23:30 · 220 阅读 · 0 评论 -
Longest Valid Parentheses
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 "()", wh原创 2015-01-08 13:27:25 · 204 阅读 · 0 评论 -
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 s3 = "aadbbcbcac", return true. When s3 = "aadbbbaccc", r原创 2014-12-22 09:01:14 · 196 阅读 · 0 评论 -
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 / \ gr原创 2015-01-01 13:57:17 · 309 阅读 · 0 评论 -
Longest Palindromic Substring
Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring. 思路: Traverse the s原创 2014-12-22 07:35:20 · 218 阅读 · 0 评论 -
Largest Rectangle in Histogram
Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram. Above is a histogram where width of ea原创 2014-10-16 13:03:59 · 259 阅读 · 0 评论