当前位置: 首页> 娱乐> 八卦 > shopify独立站好做吗_网站可以做的活动推广_免费建站系统哪个好用吗_电商代运营十大公司排名

shopify独立站好做吗_网站可以做的活动推广_免费建站系统哪个好用吗_电商代运营十大公司排名

时间:2025/7/16 2:26:51来源:https://blog.csdn.net/lynyzy/article/details/142641980 浏览次数:0次
shopify独立站好做吗_网站可以做的活动推广_免费建站系统哪个好用吗_电商代运营十大公司排名

530.二叉搜索树的最小绝对差

力扣题目链接:. - 力扣(LeetCode)

中序递归

class Solution {TreeNode pre;int res=Integer.MAX_VALUE;public int getMinimumDifference(TreeNode root) {midorder(root);return res;}public void midorder(TreeNode root){if(root==null){return;}midorder(root.left);if(pre!=null){res=Math.min(res,root.val-pre.val);}pre=root;midorder(root.right);}
}

501.二叉搜索树中的众数

力扣题目链接:. - 力扣(LeetCode)

中序递归

class Solution {int count=0;int maxcount=0;TreeNode pre=null;public int[] findMode(TreeNode root) {List<Integer> res=new ArrayList<>();midorder(root,res);int[] result=new int[res.size()];for(int i=0;i<res.size();i++){result[i]=res.get(i);}return result;}public void midorder(TreeNode root,List<Integer> res){if(root==null){return;}midorder(root.left,res);      if(pre==null||root.val!=pre.val){count=1;}else{count++;}if(count>maxcount){res.clear();res.add(root.val);maxcount=count;}else if(count==maxcount){res.add(root.val);}pre=root;midorder(root.right,res);}
}

236. 二叉树的最近公共祖先

力扣题目链接:. - 力扣(LeetCode)

class Solution {public TreeNode lowestCommonAncestor(TreeNode root, TreeNode p, TreeNode q) {if(root==null||root==p||root==q){return root;}TreeNode left=lowestCommonAncestor(root.left,p,q);TreeNode right=lowestCommonAncestor(root.right,p,q);if(left==null&&right==null){return null;}if(left!=null&&right==null){return left;}if(left==null&&right!=null){return right;}return root;}
}

关键字:shopify独立站好做吗_网站可以做的活动推广_免费建站系统哪个好用吗_电商代运营十大公司排名

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: