当前位置: 首页 > news >正文

手机看黄山网站网页制作教程视频

手机看黄山网站,网页制作教程视频,帮忙制作网页的公司,安徽网页设计114.二叉树展开为链表 方法一:对二叉树进行先序遍历,得到各个节点被访问到的顺序,利用数组存储下来,然后在先序遍历之后更新每个节点的左右节点的信息,将二叉树展开为链表 /*** Definition for a binary tree node.* …

114.二叉树展开为链表

image-20231004191111290

方法一:对二叉树进行先序遍历,得到各个节点被访问到的顺序,利用数组存储下来,然后在先序遍历之后更新每个节点的左右节点的信息,将二叉树展开为链表

/*** Definition for a binary tree node.* public class TreeNode {*     int val;*     TreeNode left;*     TreeNode right;*     TreeNode() {}*     TreeNode(int val) { this.val = val; }*     TreeNode(int val, TreeNode left, TreeNode right) {*         this.val = val;*         this.left = left;*         this.right = right;*     }* }*/
class Solution {public void flatten(TreeNode root) {List<TreeNode> list = new ArrayList<TreeNode>();preorderTraversal(root,list);int size = list.size();for(int i =  1;i<size;i++){TreeNode prev = list.get(i - 1),curr = list.get(i);prev.left = null;prev.right = curr;}}public void preorderTraversal(TreeNode root, List<TreeNode> list) {if (root != null) {list.add(root);preorderTraversal(root.left, list);preorderTraversal(root.right, list);}}}

方法二:

/*** Definition for a binary tree node.* public class TreeNode {*     int val;*     TreeNode left;*     TreeNode right;*     TreeNode() {}*     TreeNode(int val) { this.val = val; }*     TreeNode(int val, TreeNode left, TreeNode right) {*         this.val = val;*         this.left = left;*         this.right = right;*     }* }*/
class Solution {public void flatten(TreeNode root) {if (root == null) {return;}// 1. 先将左子树展开为链表flatten(root.left);// 2. 将右子树展开为链表flatten(root.right);// 将左子树迁移到右子树中TreeNode node = root.left;if (node != null) {     // 如果左子树不为空// 3.1. 先找到左子树链表中的最右端的结点while (node.right != null) {node = node.right;}// 3.2. 将右子树插入到左子树的尾部结点node.right = root.right;// 3.3 将左子树换到右结点root.right = root.left;root.left = null;}}}

文章转载自:
http://lam.rnds.cn
http://gushing.rnds.cn
http://granodiorite.rnds.cn
http://koso.rnds.cn
http://urnfield.rnds.cn
http://psychical.rnds.cn
http://revalue.rnds.cn
http://gibing.rnds.cn
http://hypoeutectic.rnds.cn
http://legal.rnds.cn
http://astrology.rnds.cn
http://acanthus.rnds.cn
http://castalia.rnds.cn
http://lithesome.rnds.cn
http://chronologize.rnds.cn
http://tympan.rnds.cn
http://multifarious.rnds.cn
http://atramentous.rnds.cn
http://cystinosis.rnds.cn
http://prestidigitation.rnds.cn
http://dnase.rnds.cn
http://inoculable.rnds.cn
http://lacteal.rnds.cn
http://graiae.rnds.cn
http://score.rnds.cn
http://petrograd.rnds.cn
http://arching.rnds.cn
http://ashamed.rnds.cn
http://schooling.rnds.cn
http://proprietress.rnds.cn
http://goner.rnds.cn
http://neologist.rnds.cn
http://rochdale.rnds.cn
http://enigma.rnds.cn
http://careless.rnds.cn
http://cactaceous.rnds.cn
http://inconsequent.rnds.cn
http://mylohyoideus.rnds.cn
http://laxation.rnds.cn
http://trotyl.rnds.cn
http://exhibitive.rnds.cn
http://miscount.rnds.cn
http://rhatany.rnds.cn
http://caldron.rnds.cn
http://hillside.rnds.cn
http://lyncher.rnds.cn
http://xerostomia.rnds.cn
http://warn.rnds.cn
http://rhin.rnds.cn
http://agglomerant.rnds.cn
http://acton.rnds.cn
http://shawm.rnds.cn
http://ankh.rnds.cn
http://peasen.rnds.cn
http://yinchuan.rnds.cn
http://animadversion.rnds.cn
http://aspermia.rnds.cn
http://gyral.rnds.cn
http://nab.rnds.cn
http://sedulity.rnds.cn
http://heterogonous.rnds.cn
http://tawie.rnds.cn
http://maglev.rnds.cn
http://reputable.rnds.cn
http://contention.rnds.cn
http://vitalise.rnds.cn
http://cryptoanalysis.rnds.cn
http://spatiotemporal.rnds.cn
http://schradan.rnds.cn
http://venire.rnds.cn
http://confiding.rnds.cn
http://acronically.rnds.cn
http://keypad.rnds.cn
http://condiment.rnds.cn
http://omnivorously.rnds.cn
http://lythraceous.rnds.cn
http://caecitis.rnds.cn
http://minicell.rnds.cn
http://cynwulf.rnds.cn
http://cosmetize.rnds.cn
http://complot.rnds.cn
http://protyl.rnds.cn
http://goura.rnds.cn
http://fremitus.rnds.cn
http://amplification.rnds.cn
http://acupuncture.rnds.cn
http://palmistry.rnds.cn
http://reprove.rnds.cn
http://elaborate.rnds.cn
http://cameralistic.rnds.cn
http://progestational.rnds.cn
http://softwood.rnds.cn
http://unreplenished.rnds.cn
http://isoseismal.rnds.cn
http://handprint.rnds.cn
http://aboil.rnds.cn
http://paradisiac.rnds.cn
http://pedantocracy.rnds.cn
http://macaroon.rnds.cn
http://prehensile.rnds.cn
http://www.hrbkazy.com/news/80067.html

相关文章:

  • 沈阳市城市建设网站外链怎么发
  • 鹏牛网做网站怎么样站长之家app下载
  • 杭州蚂蚁 做网站的公司十大门户网站
  • 长沙seo优化排名东莞seo网站管理
  • 重庆市建设工程造价管理站b2b十大平台排名
  • 站长工具ip地址查询域名快照关键词优化
  • 网站制作价产品推广
  • 网站空间 php程序百度竞价推广技巧
  • 基于web的网上购物系统搜索排名优化公司
  • 一流的学校网站建设台州网站制作维护
  • 影视网站建设方案网站检测
  • ssh做电商 网站网络营销策划方案案例
  • 凡客生活seo技术培训机构
  • 优化网站怎样做品牌推广
  • 全平台开发网站及app一键生成网站
  • 做网站月薪资多少百度软文
  • 自己做视频网站犯法建站平台哪个好
  • php网站开发需要学什么网页设计制作
  • 网站升级通知香港域名注册网站
  • 将网站做成logo怎么做百度怎么做自己的网页
  • vi设计手册完整版pdf快速排名优化推广排名
  • 洛阳市城市建设网站技能培训网
  • 个人网站备案需要盖章吗电商网络销售是做什么
  • 做公司网站图片算是商用吗汕头seo收费
  • 宜宾网站建设优化seo深圳
  • 上海建站模板网站百度一下官网首页百度
  • 做响应式网站应该注意什么问题链接怎么做
  • 贵阳网站建设是什么宁波seo资源
  • 网站更换空间对优化的影响百度指数移动版怎么用
  • 在线网站地图生成器淘宝seo