摘要:
还好做出来了,就是慢了点。 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)) 阅读全文
摘要:
import static java.lang.Integer.min; class Solution { public int minDistance(String word1, String word2) { int m = word1.length(); int n = word2.lengt 阅读全文
摘要:
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 阅读全文
摘要:
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; 阅读全文
摘要:
动态规划好巧妙啊啊啊啊啊啊啊 啊 int max =Integer.MIN_VALUE; public int maxPathSum(TreeNode root) { //用动态规划来求解 //DFS //根节点的值、左子树的值、右子树的值、 dfs(root); return max; } pri 阅读全文
摘要:
class Solution { //定义一个数组,用于存放每一列的皇后放置的位置 List<List<String>> result = new ArrayList<>(); public List<List<String>> solveNQueens(int n) { //N皇后 int[] c 阅读全文
摘要:
思路错一点点,努力都是白费。 public String reorganizeString(String S) { int N = S.length(); int[] counts = new int[26]; for (char c: S.toCharArray()) counts[c-'a'] 阅读全文