![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
DP
文章平均质量分 73
CSLDBLYDX
这个作者很懒,什么都没留下…
展开
-
Uva 1121 Subsequence
#include #include #include #include using namespace std;const int MAX = 100000 + 5; const long MAX_VAL = 1000000000 + 5;long arr[MAX]; int main(int argc, char *argv[]){ int n,s;原创 2014-05-07 20:26:12 · 417 阅读 · 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 "()",原创 2015-01-12 21:27:40 · 283 阅读 · 0 评论 -
Maximum Product Subarray
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 largest原创 2015-01-12 19:42:14 · 280 阅读 · 0 评论 -
Word Break
Given a string s and a dictionary of words dict, determine ifs can be segmented into a space-separated sequence of one or more dictionary words.For example, givens = "leetcode",dict = ["leet",原创 2014-12-24 13:22:29 · 286 阅读 · 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原创 2015-01-12 18:07:18 · 372 阅读 · 0 评论 -
Maximum Subarray
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原创 2015-01-12 18:35:16 · 288 阅读 · 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 since the palindrome partitioning ["aa","b"] could be produc原创 2015-01-10 18:51:50 · 338 阅读 · 0 评论 -
Dungeon Game
The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out in a 2D grid. Our valiant knight (K) was initially pos原创 2015-01-14 11:53:00 · 295 阅读 · 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 number原创 2015-01-14 16:48:21 · 278 阅读 · 0 评论 -
Best Time to Buy and Sell Stock III
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原创 2015-01-14 18:42:15 · 356 阅读 · 0 评论 -
Climbing Stairs
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? class Solution原创 2015-01-14 17:12:22 · 385 阅读 · 0 评论 -
Distinct Subsequences
Given a string S and a string T, count the number of distinct subsequences ofT in S.A subsequence of a string is a new string which is formed from the original string by deleting some (can b原创 2015-01-14 12:58:20 · 409 阅读 · 0 评论 -
Word Break II
Given a string s and a dictionary of words dict, add spaces ins to construct a sentence where each word is a valid dictionary word.Return all such possible sentences.For example, givens = "cat原创 2014-12-24 21:52:52 · 448 阅读 · 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", retur原创 2015-01-13 17:52:58 · 309 阅读 · 0 评论 -
Regular Expression Matching
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原创 2015-01-10 13:55:33 · 487 阅读 · 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 / \原创 2015-01-09 15:12:09 · 358 阅读 · 0 评论 -
UVA 1398 - Meteor
#include #include #include #include using namespace std;const int MAX = 100000 + 5;const int MAX_T = 1000000000 + 5;struct point{ int t,type;//t = -1 表示是下界 1表示上界 bool operator原创 2014-05-07 15:45:00 · 361 阅读 · 0 评论 -
Poj 1964 City Game
City GameTime Limit: 3000MS Memory Limit: 30000KTotal Submissions: 4730 Accepted: 1876DescriptionBob is a strategy game programming specialist. In his new city buil原创 2014-05-26 12:21:32 · 367 阅读 · 0 评论 -
poj 3141Distant Galaxy
#include #include #include #include using namespace std;const int MAX = 100+5;struct P{ int x,y; bool operator <(const P& point) const { return x < point.x; }原创 2014-07-22 20:54:19 · 564 阅读 · 0 评论 -
uva10755 - Garbage Heap
#include #include #include #define FOR(i,s,t) for(int i = ( s); i < (t); i++)#define max(i,j) (i > j ? i : j)#define min(i,j) (i < j ? i : j)using namespace std;const int MAX = 20 + 3; cons原创 2014-07-24 00:09:01 · 445 阅读 · 0 评论 -
1401 - Remember the Word
Neal is very curious about combinatorial problems, and now here comes a problem about words. Knowing that Ray has a photographic memory and this may not trouble him, Neal gives it to Jiejie.Since原创 2014-10-28 21:14:35 · 457 阅读 · 0 评论 -
Wildcard Matching
class Solution {public: // int *dp; bool isMatch(const char *s, const char *p) { if(s == NULL || p == NULL)return false; int slen = strlen(s); int plen = strlen(p); //尽可能的想到特殊情况原创 2015-01-06 19:15:20 · 368 阅读 · 0 评论 -
Unique Paths
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 bo原创 2015-01-07 12:05:00 · 298 阅读 · 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 grid.原创 2015-01-07 12:43:06 · 235 阅读 · 0 评论 -
Unique Binary Search Trees II
Given 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 below. 1 3原创 2015-01-07 22:01:34 · 339 阅读 · 0 评论 -
Unique Binary Search Trees
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 1 \原创 2015-01-07 20:37:40 · 311 阅读 · 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. class Solution {public: vector > lreach,upreach,rreach; void set_re原创 2014-12-18 21:08:48 · 293 阅读 · 0 评论 -
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], [6,原创 2015-01-09 12:47:13 · 389 阅读 · 0 评论 -
Edit Distance
Given two words word1 and word2, find the minimum number of steps required to convertword1 to word2. (each operation is counted as 1 step.)You have the following 3 operations permitted on a原创 2015-01-13 22:37:22 · 298 阅读 · 0 评论