上一页 1 ··· 9 10 11 12 13 14 15 16 17 ··· 33 下一页
摘要: public List<List<String>> partition(String s) { int len = s.length(); List<List<String>> totalList = new ArrayList<>(); if(len == 0){ return totalList 阅读全文
posted @ 2020-06-28 15:29 欣姐姐 阅读(142) 评论(0) 推荐(0) 编辑
摘要: 这道题的动态规划,我自己没有想清楚,看了答案之后才恍然大悟,不难。 public boolean wordBreak(String s, List<String> wordDict) { boolean[] f = new boolean[s.length()+1]; f[0] = true; fo 阅读全文
posted @ 2020-06-27 21:45 欣姐姐 阅读(101) 评论(0) 推荐(0) 编辑
摘要: 还好做出来了,就是慢了点。 public int numDistinct(String s, String t) { int m = s.length(); int n = t.length(); if(m<n){ return 0; }else if(m ==n){ if(s.equals(t)) 阅读全文
posted @ 2020-06-27 17:36 欣姐姐 阅读(74) 评论(0) 推荐(0) 编辑
摘要: import static java.lang.Integer.min; class Solution { public int minDistance(String word1, String word2) { int m = word1.length(); int n = word2.lengt 阅读全文
posted @ 2020-06-27 14:40 欣姐姐 阅读(163) 评论(0) 推荐(0) 编辑
摘要: 动态规划,还是学不会,,这道题好难啊!!!! 但是思路对了之后又是如此清晰。 public boolean isScramble(String s1, String s2) { if(s1.length() != s2.length()){ return false; } int len = s1. 阅读全文
posted @ 2020-06-27 13:11 欣姐姐 阅读(165) 评论(0) 推荐(0) 编辑
摘要: public int maxProfit(int[] prices) { int n = prices.length; if(n<2){ return 0; } int[] f = new int[n]; int[] g = new int[n]; for(int i = 1,valley = pr 阅读全文
posted @ 2020-06-25 17:41 欣姐姐 阅读(111) 评论(0) 推荐(0) 编辑
摘要: public int minCut(String s) { int n = s.length(); int[] f = new int[n+1]; boolean[][] p = new boolean[n][n]; for (int i = 0;i<= n;i++){ f[i] = n-1-i; 阅读全文
posted @ 2020-06-24 23:02 欣姐姐 阅读(133) 评论(0) 推荐(0) 编辑
摘要: 动态规划好巧妙啊啊啊啊啊啊啊 啊 int max =Integer.MIN_VALUE; public int maxPathSum(TreeNode root) { //用动态规划来求解 //DFS //根节点的值、左子树的值、右子树的值、 dfs(root); return max; } pri 阅读全文
posted @ 2020-06-24 21:11 欣姐姐 阅读(144) 评论(0) 推荐(0) 编辑
摘要: class Solution { //定义一个数组,用于存放每一列的皇后放置的位置 List<List<String>> result = new ArrayList<>(); public List<List<String>> solveNQueens(int n) { //N皇后 int[] c 阅读全文
posted @ 2020-06-24 15:51 欣姐姐 阅读(130) 评论(0) 推荐(0) 编辑
摘要: 思路错一点点,努力都是白费。 public String reorganizeString(String S) { int N = S.length(); int[] counts = new int[26]; for (char c: S.toCharArray()) counts[c-'a'] 阅读全文
posted @ 2020-06-23 15:35 欣姐姐 阅读(141) 评论(0) 推荐(0) 编辑
上一页 1 ··· 9 10 11 12 13 14 15 16 17 ··· 33 下一页