随笔分类 -  dp 3

139 Word Break
摘要:Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequ 阅读全文

posted @ 2018-11-06 07:40 猪猪🐷

140 Word Break II
摘要:Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, add spaces in s to construct a sentence where each word is a valid dictionary word. Return all such possible... 阅读全文

posted @ 2018-11-06 07:40 猪猪🐷

91. 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 a non-empty string containing only digits, determine the total num... 阅读全文

posted @ 2018-11-06 07:39 猪猪🐷

279. Perfect Squares
摘要:Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n. Example 1: Input: n = 12 Output: 3 Explanation: 12 = 4 + 4 + 4. Example 2:... 阅读全文

posted @ 2018-11-06 07:38 猪猪🐷

131. Palindrome Partitioning
摘要:dfs dfs + preprocessing 阅读全文

posted @ 2018-11-06 07:37 猪猪🐷

decode ways
摘要:// dfs class Solution { public int numDecodings(String s) { if(s == null || s.length() == 0) return 0; return dfs(s, 0); } private int dfs(String s, int i){ if(i ... 阅读全文

posted @ 2018-09-08 07:33 猪猪🐷

word break
摘要:// Time complexity : O(n^2)// Two loops are their to fill dp array. //Space complexity : O(n). Length of pp array is n+1 阅读全文

posted @ 2018-09-08 07:07 猪猪🐷

140. Word Break II
摘要:140. Word Break II dfs + memo Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, add spaces in s to construct 阅读全文

posted @ 2018-08-10 15:26 猪猪🐷

导航