动态规划
crazy__chen
只要有一个人爱我,懂我,愿意等我,我便勇往直前,无所不能。
展开
-
leetcode--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",原创 2015-06-19 17:22:40 · 771 阅读 · 0 评论 -
leetcode--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] has原创 2015-06-06 16:28:53 · 685 阅读 · 0 评论 -
最长公共子序列&最长公共子串
最长公共子序列 & 最长公共子串的区别:找两个字符串的最长公共子串,这个子串要求在原字符串中是连续的。而最长公共子序列则并不要求连续。最长公共子序列的问题参考:最长公共子序列。String solve(String str1,String str2){ StringBuilder sb = new StringBuilder(); if (str1 == null || str1.原创 2015-05-01 23:09:29 · 1067 阅读 · 0 评论 -
leetcode--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, givens = "原创 2015-08-08 15:11:51 · 1045 阅读 · 0 评论 -
leetcode--Wildcard Matching
Implement wildcard pattern matching with support for '?' and '*'.'?' Matches any single character.'*' Matches any sequence of characters (including the empty sequence).The matching should cover t原创 2015-08-08 16:43:41 · 978 阅读 · 0 评论 -
leetcode--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 pr原创 2015-06-20 13:02:50 · 601 阅读 · 0 评论 -
leetcode--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-06-08 10:32:59 · 710 阅读 · 0 评论 -
leetcode--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-06-08 09:32:12 · 862 阅读 · 0 评论 -
leetcode--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-08-09 16:31:29 · 1316 阅读 · 0 评论 -
leetcode--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-06-14 21:03:11 · 862 阅读 · 0 评论 -
剑指offer--连续子数组的最大和
题目描述HZ偶尔会拿些专业问题来忽悠那些非计算机专业的同学。今天测试组开完会后,他又发话了:在古老的一维模式识别中,常常需要计算连续子向量的最大和,当向量全为正数的时候,问题很好解决。但是,如果向量中包含负数,是否应该包含某个负数,并期望旁边的正数会弥补它呢?例如:{6,-3,-2,7,-15,1,2,2},连续子向量的最大和为8(从第0个开始,到第3个为止)。你会不会被他忽悠住? publi原创 2015-04-12 12:50:39 · 946 阅读 · 0 评论