摘要:
124.二叉树的最大路径和 public int maxPathSum(TreeNode root) { if(root == null) { return 0; } return process(root).max; } public Info process(TreeNode root) { i 阅读全文
摘要:
188.买卖股票的最佳时机4 public int maxProfit(int k, int[] prices) { if (prices == null || prices.length == 0) { return 0; } int N = prices.length; if (k >= N / 阅读全文
摘要:
剑指Offer 47 public int maxValue(int[][] grid) { int M = grid.length; int N = grid[0].length; int dp[][] = new int[M][N]; dp[0][0] = grid[0][0]; for(int 阅读全文
摘要:
103.二叉树的锯齿形层序遍历 public List<List<Integer>> zigzagLevelOrder(TreeNode root) { List<List<Integer>> res = new ArrayList<>(); if(root == null) { return re 阅读全文
摘要:
91.解码方法 public int numDecodings(String s) { char s1[] = s.toCharArray(); int N = s1.length; int dp[] = new int[N + 1]; dp[N] = 1; for(int index = N - 阅读全文