摘要: public boolean isBalanced(TreeNode root) { if (root == null) { return true; } int diff = getDepth(root.left) - getDepth(root.right); diff = diff > 0 ? 阅读全文
posted @ 2020-07-15 17:01 牛有肉 阅读(147) 评论(0) 推荐(0)
摘要: 回溯解法: int an = 0; public final int getMaximumGold(int[][] grid) { for (int i = 0; i < grid.length; i++) { for (int j = 0; j < grid[0].length; j++) { g 阅读全文
posted @ 2020-07-15 15:16 牛有肉 阅读(218) 评论(0) 推荐(0)
摘要: 一道中规中矩的 DP 题目,但因为问题空间较大,需要做一些优化。 分治法: int an = 0; public final int longestSubsequence(int[] arr, int difference) { if (arr.length == 0) { return 0; } 阅读全文
posted @ 2020-07-15 14:22 牛有肉 阅读(203) 评论(0) 推荐(0)