摘要: 记忆化递归: int max = 0; public int lenLongestFibSubseq(int[] A) { int[][] cache = new int[A.length][A.length]; for (int i = 0; i < A.length - 1; i++) { fo 阅读全文
posted @ 2020-06-28 23:47 牛有肉 阅读(254) 评论(0) 推荐(0)
摘要: 借助全局变量 max 存储全局最优解,遍历以所有节点为头结点的子树。 static final int LEFT = -1; static final int RIGHT = 1; int max = 0; public final int longestZigZag(TreeNode root) 阅读全文
posted @ 2020-06-28 21:18 牛有肉 阅读(293) 评论(0) 推荐(0)