随笔分类 -  LeetCode热门200题题库

摘要:本体关键就是二叉树加递归 在递归中用int数组保存需要的内容 //二叉树加递归 注意int[]返回值很关键 public class L333 { private int ans; public int largestBSTSubtree(TreeNode root) { isBST(root); 阅读全文
posted @ 2022-05-09 10:01 fao99 阅读(78) 评论(0) 推荐(0) 编辑
摘要:动态规划 public int minCost(int[][] costs) { int[][] dp=new int[costs.length][3]; dp[0][0]=costs[0][0]; dp[0][1]=costs[0][1]; dp[0][2]=costs[0][2]; for(in 阅读全文
posted @ 2022-05-05 10:27 fao99 阅读(42) 评论(0) 推荐(0) 编辑
摘要:class Solution { public boolean verifyPreorder(int[] preorder) { LinkedList<Integer> stack=new LinkedList<>(); int preElem=Integer.MIN_VALUE; for(int 阅读全文
posted @ 2022-04-27 13:08 fao99 阅读(42) 评论(0) 推荐(0) 编辑
摘要:构建二叉树的题 class Solution { public TreeNode upsideDownBinaryTree(TreeNode root) { if(root==null){ return null; } if(root.left==null){ return root; } Tree 阅读全文
posted @ 2022-04-26 11:26 fao99 阅读(34) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示