DP
文章平均质量分 65
WayneShan
这个作者很懒,什么都没留下…
展开
-
【LeetCode】【JAVA】【063】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 g原创 2015-03-24 12:57:17 · 120 阅读 · 0 评论 -
【LeetCode】【JAVA】【081】Word Break
题目:http://oj.leetcode.com/problems/word-break/ 思路: DP,res[i] 的 boolean 数组记录第 ith 位可否被 break。res[ j ] && wordDict.contains( s.substring( j , i+1 )) 判断第 ith 位可否被 break。遍历检测,知道 string 的最后一位。 参考:ht原创 2015-04-29 03:28:39 · 158 阅读 · 0 评论 -
【LeetCode】【JAVA】【085】Word Break II
题目:https://leetcode.com/problems/word-break-ii/ 思路: 直接用 Recursion超时。取 Word Break 的思路,先 DP 获得 jth 位置可达到的 index,再通过 Recursion 获得所有结果。 Code: public class Solution { ArrayList resAL;原创 2015-04-29 23:29:34 · 163 阅读 · 0 评论