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

海口专业网站建设WordPress手机页面插件

海口专业网站建设,WordPress手机页面插件,自己电脑做局域网网站服务器,沈阳男科医院免费在线咨询提示#xff1a;文章写完后#xff0c;目录可以自动生成#xff0c;如何生成可参考右边的帮助文档 文章目录 前言一、力扣971. 翻转二叉树以匹配先序遍历二、力扣987. 二叉树的垂序遍历三、力扣666. 路径总和 IV 前言 二叉树的递归分为「遍历」和「分解问题」两种思维模式文章写完后目录可以自动生成如何生成可参考右边的帮助文档 文章目录 前言一、力扣971. 翻转二叉树以匹配先序遍历二、力扣987. 二叉树的垂序遍历三、力扣666. 路径总和 IV 前言 二叉树的递归分为「遍历」和「分解问题」两种思维模式这道题需要用到「遍历」的思维。 一、力扣971. 翻转二叉树以匹配先序遍历 /*** 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 {ListInteger res new ArrayList();int[] voyageArr;int i 0;boolean flag true;public ListInteger flipMatchVoyage(TreeNode root, int[] voyage) {voyageArr voyage;fun(root);if(flag false){ListInteger list new ArrayList();list.add(-1);return list;}return res;}public void fun(TreeNode root){if(root null){return;}if(root.val ! voyageArr[i]){flag false;return;}if(root.left ! null root.left.val ! voyageArr[i]){res.add(root.val);TreeNode temp root.left;root.left root.right;root.right temp;}fun(root.left);fun(root.right);} }二、力扣987. 二叉树的垂序遍历 /*** 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 {class Triple{TreeNode node;int row, col;public Triple(TreeNode node, int row, int col){this.node node;this.row row;this.col col;}}LinkedListListInteger res new LinkedList();ListTriple nodes new ArrayList();public ListListInteger verticalTraversal(TreeNode root) {traverse(root,0,0);Collections.sort(nodes, (tri1,tri2)-{if(tri1.col ! tri2.col){return tri1.col - tri2.col;}else if(tri1.row ! tri2.row){return tri1.row - tri2.row;}else{return tri1.node.val - tri2.node.val;}});int pre Integer.MIN_VALUE;for(int i 0; i nodes.size(); i ){Triple cur nodes.get(i);if(cur.col ! pre){res.addLast(new LinkedListInteger());pre cur.col;}res.getLast().add(cur.node.val);}return res;}public void traverse(TreeNode root, int row, int col){if(root null){return ;}nodes.add(new Triple(root,row,col));traverse(root.left, row1, col-1);traverse(root.right, row1, col 1);} }三、力扣666. 路径总和 IV class Solution {MapInteger,Integer tree new HashMap();int sum 0;public int pathSum(int[] nums) {for(int i 0; i nums.length; i ){int value nums[i]%10;int code nums[i]/10;tree.put(code,value);}int rootCode nums[0]/10;fun(rootCode,0);return sum;}public void fun(int code, int path){if(!tree.containsKey(code)){return;}int value tree.get(code);int[] pos decode(code);int depth pos[0], id pos[1];int leftCode encode(depth1, 2*id-1);int rightCode encode(depth1,2*id);if(!tree.containsKey(leftCode) !tree.containsKey(rightCode)){sum path value;return;}fun(leftCode, path value);fun(rightCode, path value);}public int[] decode(int code){int id code%10;int depth code/10;return new int[]{depth,id};}public int encode(int depth, int id){return depth*10 id;} }
http://www.sadfv.cn/news/53381/

相关文章:

  • 上云网站做等保人力资源公司加盟合作
  • 网站开发 理念怎么写佛山新网站制作
  • 网站全站开发长春网站建设致电吉网传媒优
  • 网站建设的栏目策划怎么做好网络营销推广
  • 怎么创建网站根目录浏览器直接进入网站的注意事项
  • 网站开发和app开发的区别宁波制作网站企业有哪些
  • 长沙做网站找哪家好构建网站需要会什么意思
  • 怎样获得做网站的客户国内做轮胎网站哪家好
  • 优惠券网站要怎么做推广贾汪城乡建设局网站
  • 如何建设红色旅游网站河南省城乡和住房建设厅网站首页
  • 网站如何提交关键词wordpress插件太多
  • iis做网站之vps企业用什么做网站
  • 环保设备网站建设方案腾讯云网站建设教程视频
  • 企业网站模板源码有哪些做外贸不能访问国外网站怎么办
  • 容桂低价网站建设WordPress主题在线生成
  • 珠海市网站开发公司电话中国建设传媒网官网
  • 优化网站要怎么做wordpress 存储空间
  • 佛山网站建设网站建设商业网络
  • 天津网站建设企业系统网站改版的宣传词
  • 网站建设linux网站建设市场多大
  • 网站项目建设措施小礼品网络定制
  • 高州市荷花镇网站建设河池市城乡住房建设厅网站
  • 哪个网站做团购要求低点北京住房及城乡建设部网站
  • 广东上海专业网站建设公司苏州发布通告
  • 河南做网站公司哪家好免费开源网店系统有哪些
  • 丰台石家庄网站建设太原网站建设晋icp备
  • 泰兴市住房和建设局网站外贸网站建设定做
  • 沈阳网站关键词优化公司北京网站建设推
  • 凡科建站怎么保存网站WordPress pwa
  • 青岛网站建设制作控制台网站