
DP
zhaobaoxue
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Generate Parentheses
class Solution {public: vector generateParenthesis(int n) { vector result; string path; dfs(n, 0, 0, path, result); return result; } void dfs(int n, int l,转载 2014-04-07 17:18:03 · 447 阅读 · 0 评论 -
Spiral Matrix
注意细节。class Solution {public: vector spiralOrder(vector > &matrix) { vector result; int row = matrix.size(); if(row == 0) return result; int col = matrix原创 2014-09-10 20:22:49 · 380 阅读 · 0 评论 -
Palindrome Number
和Reverse Integer类似,按位处理,而不要转换成String。原创 2014-09-10 12:08:11 · 386 阅读 · 0 评论 -
Edit Distance
DP+滚动数组。注意长度原创 2014-09-09 19:44:31 · 422 阅读 · 0 评论 -
Distinct Subsequences
题目描述:Given a string S and a string T, count the number of distinct subsequences ofT inS.A subsequence of a string is a new string which is formed from the original string by deleting some转载 2014-09-09 21:08:26 · 475 阅读 · 0 评论 -
Word Break
DPclass Solution {public: bool wordBreak(string s, unordered_set &dict) { const int n = s.size(); if(n == 0) return true; vector f(n+1, false); f[0] = true;原创 2014-09-09 21:48:55 · 381 阅读 · 0 评论 -
Decode Ways
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 nu原创 2014-04-15 11:57:15 · 437 阅读 · 0 评论 -
Maximal Rectangle
三种方法,第一种参考 http://blog.youkuaiyun.com/fightforyourdream/article/details/17711893Time O(n^3),原创 2014-09-09 15:43:11 · 440 阅读 · 0 评论 -
Minimum Path Sum
DP + 滚动数组,注意首行和首列特殊处理。原创 2014-09-09 18:07:32 · 388 阅读 · 0 评论 -
Scramble String
DP, Time O(n^4), Space O(n^3)。原创 2014-09-09 17:55:51 · 387 阅读 · 0 评论 -
Interleaving String
1. 2维 DP。class Solution {public: bool isInterleave(string s1, string s2, string s3) { const int n1 = s1.size(); const int n2 = s2.size(); const int n3 = s3.size();原创 2014-09-09 16:46:22 · 382 阅读 · 0 评论 -
Palindrome Partitioning II
DP.先利用DP计算每个substr是否原创 2014-09-09 11:44:52 · 378 阅读 · 0 评论 -
Reverse Integer
注意处理overflow和negative的问题。class Solution {public: int reverse(int x) { bool positive = (x>=0); x = abs(x); int result = 0; for(; x; x/=10)原创 2014-09-10 11:54:03 · 357 阅读 · 0 评论