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

中国网页设计师网站网站seo推广招聘

中国网页设计师网站,网站seo推广招聘,中国人民解放军文职考试一年几次,网站建设番禺目录 模版 先序遍历 中序遍历 后序遍历 力扣原题 相同的二叉树 力扣原题 翻转二叉树 遍历树的层数 题目 静态变量 核心逻辑 模版 // 二叉树public static class Node{public int value;public Node left;public Node right;public Node(int v) {valuev;}} 先序遍历 …

目录

模版

先序遍历

中序遍历

后序遍历

力扣原题 相同的二叉树

力扣原题 翻转二叉树

遍历树的层数

题目

静态变量

核心逻辑


模版

    // 二叉树public static class Node{public int value;public Node left;public Node right;public Node(int v) {value=v;}}

先序遍历

根节点 左孩子节点 右孩子节点

中序遍历

左孩子节点 根节点 右孩子节点

后序遍历

左孩子节点 右孩子节点 根节点

力扣原题 相同的二叉树

100. 相同的树 - 力扣(LeetCode)

/*** 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 boolean isSameTree(TreeNode p, TreeNode q) {if(p==null && q!=null){return false;}if(p!=null && q==null){return false;}if(p==null && q==null){return true;}// 都不为空return p.val==q.val && isSameTree(p.left,q.left) && isSameTree(p.right,q.right);}
}

力扣原题 翻转二叉树

/*** 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 TreeNode flipTree(TreeNode root) {if(root == null) return null;TreeNode tmp = root.left;root.left = flipTree(root.right);root.right = flipTree(tmp);return root;}
}

遍历树的层数

题目

静态变量

核心逻辑

import java.util.*;
import java.math.*;
import java.time.*;
import java.io.*;
import java.util.regex.*;// Eclipse IDE 2020 08
// OpenJDK 1.8
// 下方网页是个人主页
// http://gczdy.cn/*.-'''-.     
_______     _______               '   _    \   
\  ___ `'.  \  ___ `'.          /   /` '.   \  ' |--.\  \  ' |--.\  \        .   |     \  '  | |    \  ' | |    \  '       |   '      |  ' | |     |  '| |     |  '      \    \     / /  | |     |  || |     |  | _    _`.   ` ..' /   | |     ' .'| |     ' .'| '  / |  '-...-'`    | |___.' /' | |___.' /'.' | .' |              
/_______.'/ /_______.'/ /  | /  |              
\_______|/  \_______|/ |   `'.  |              '   .'|  '/             `-'  `--'              
*//*** * @Author Dduo* @Date 2025-01-10*/
public class Main {//    普通流
//    static Scanner sc = new Scanner(System.in);//    数据流快读模板(类似于C++的IOS)static Read sc=new Read();//    时间类 用来测试运行时间static Instant START=Instant.now();static long MOD = (long) (1e9 + 7);static int[] dx = {0, 0, 1, -1, 1, -1, 1, -1};static int[] dy = {1, -1, 0, 0, -1, -1, 1, 1};private static final int[] DIRECTIONS = {-1, 0, 1, 0, -1};/**** @param args* @return* @throws Exception */public static void main(String[] args) throws Exception {int t = 1;
//        t = sc.nextInt();//      预处理preconditioning();while (t-- > 0) {solve();}//   	 	sc.close();
//			dduoln("运行时间 : "+Duration.between(START,Instant.now()).toMillis()+"ms");return;}//    输出流  static <T> void dduoln(T t) {System.out.println(t);}static <T> void dduo(T t) {System.out.print(t);}//  预处理static void preconditioning() {}//    数据结构模板 二叉树 by Dduostatic class Node{public int value;public Node left;public Node right;public Node() {}public Node(int v) {value=v;}}//    静态变量static Node[] a = new Node[1000010];static int cnt=0;//    核心代码逻辑static void solve() throws Exception { 	// 构造二叉树int n=sc.nextInt();for(int i=1;i<=n;i++) {a[i]=new Node(i);int l=sc.nextInt();int r=sc.nextInt();if (l != 0) {a[i].left = new Node(l);}if (r != 0) {a[i].right = new Node(r);}}dfs(a[1],1);dduoln(cnt);}static void dfs(Node node,int max){
//    	   System.out.println("Visiting Node " + node.value + " at depth " + max);// 判断当前节点是否是叶子节点(即左右子节点都为null)if (node.left == null && node.right == null) {cnt = Math.max(cnt, max);return; }// 遍历左子树if (node.left != null) {dfs(a[node.left.value], max + 1);}// 遍历右子树if (node.right != null) {dfs(a[node.right.value], max + 1);}}// 快速幂模版 by Dduostatic long pow(long a, long b) {if (b == 0) return 1;if (b == 1) return a;try {long result = 1;while (b > 0) {if ((b & 1) == 1) {if (result > Long.MAX_VALUE / a) return Long.MAX_VALUE;result *= a;}b >>= 1;if (b > 0) {if (a > Long.MAX_VALUE / a) return Long.MAX_VALUE;a *= a;}}return result;} catch (Exception e) {return Long.MAX_VALUE;}}
}// 数据结构模版 并查集 by Dduo
class UnionFind {private int[] parent;private int[] size;// 初始化并查集public UnionFind(int n) {parent = new int[n + 1]; // 因为编号从 1 到 N,所以数组大小是 N+1size = new int[n + 1];for (int i = 1; i <= n; i++) {parent[i] = i; // 每个元素的父节点初始为自己size[i] = 1;   // 每个元素的初始大小为 1}}// 查找元素 x 所在的集合,带路径压缩优化public int find(int x) {if (parent[x] != x) {parent[x] = find(parent[x]);  // 路径压缩}return parent[x];}// 合并两个集合 带按秩合并优化public void union(int x, int y) {int rootX = find(x);int rootY = find(y);if (rootX != rootY) {// 按秩合并 较小的树合并到较大的树上if (size[rootX] < size[rootY]) {parent[rootX] = rootY;size[rootY] += size[rootX];} else {parent[rootY] = rootX;size[rootX] += size[rootY];}}}// 判断 x 和 y 是否在同一个集合中public boolean connected(int x, int y) {return find(x) == find(y);}
}// 数据流快读模板(类似于C++的IOS) by Dduo
class Read{BufferedReader bf;StringTokenizer st;BufferedWriter bw;public Read(){bf=new BufferedReader(new InputStreamReader(System.in));st=new StringTokenizer("");bw=new BufferedWriter(new OutputStreamWriter(System.out));}
//    以下为输入部分:public String nextLine() throws IOException{return bf.readLine();}public String next() throws IOException{while(!st.hasMoreTokens()){st=new StringTokenizer(bf.readLine());}return st.nextToken();}public char nextChar() throws IOException{//确定下一个token只有一个字符的时候再用return next().charAt(0);}public int nextInt() throws IOException{return Integer.parseInt(next());}public long nextLong() throws IOException{return Long.parseLong(next());}public double nextDouble() throws IOException{return Double.parseDouble(next());}public float nextFloat() throws IOException{return Float.parseFloat(next());}public byte nextByte() throws IOException{return Byte.parseByte(next());}public short nextShort() throws IOException{return Short.parseShort(next());}public BigInteger nextBigInteger() throws IOException{return new BigInteger(next());}public BigDecimal nextDecimal() throws IOException{return new BigDecimal(next());}
//    以下为输出部分:public void println(int a) throws IOException{print(a);println();return;}public void print(int a) throws IOException{bw.write(String.valueOf(a));return;}public void println(String a) throws IOException{print(a);println();return;}public void print(String a) throws IOException{bw.write(a);return;}public void println(long a) throws IOException{print(a);println();return;}public void print(long a) throws IOException{bw.write(String.valueOf(a));return;}public void println(double a) throws IOException{print(a);println();return;}public void print(double a) throws IOException{bw.write(String.valueOf(a));return;}public void print(BigInteger a) throws IOException{bw.write(a.toString());return;}public void print(char a) throws IOException{bw.write(String.valueOf(a));return;}public void println(char a) throws IOException{print(a);println();return;}public void println() throws IOException{bw.newLine();return;}
//    其他调试命令:public void flush() throws IOException{
//      交互题分组调试,或者提前退出的情况下可以先运行此语句再推出bw.flush();return;}public boolean hasNext() throws IOException{
//      本地普通IDE难以使用这个方法调试,需要按照数据组flush,刷新语句:
//      sc.flush()
//      调试完可删去return bf.ready();}
}

文章转载自:
http://reappointment.gthc.cn
http://oujda.gthc.cn
http://piat.gthc.cn
http://keenly.gthc.cn
http://anginal.gthc.cn
http://obdurately.gthc.cn
http://suspicious.gthc.cn
http://olaf.gthc.cn
http://adenalgia.gthc.cn
http://pellucid.gthc.cn
http://liable.gthc.cn
http://concretive.gthc.cn
http://crushhat.gthc.cn
http://leaper.gthc.cn
http://thomist.gthc.cn
http://traversable.gthc.cn
http://hoy.gthc.cn
http://lamergeyer.gthc.cn
http://marsquake.gthc.cn
http://concours.gthc.cn
http://incompatibility.gthc.cn
http://autoclavable.gthc.cn
http://drawspring.gthc.cn
http://whiskey.gthc.cn
http://lyingly.gthc.cn
http://sucrase.gthc.cn
http://coenogenetic.gthc.cn
http://estivation.gthc.cn
http://skandalon.gthc.cn
http://psychobiology.gthc.cn
http://tramp.gthc.cn
http://unprompted.gthc.cn
http://minibudget.gthc.cn
http://daut.gthc.cn
http://seastar.gthc.cn
http://indefective.gthc.cn
http://poussette.gthc.cn
http://fosterer.gthc.cn
http://countershaft.gthc.cn
http://neighbourhood.gthc.cn
http://teether.gthc.cn
http://misology.gthc.cn
http://crawl.gthc.cn
http://inleakage.gthc.cn
http://isochroous.gthc.cn
http://bri.gthc.cn
http://phlogosis.gthc.cn
http://ohmage.gthc.cn
http://excommunicative.gthc.cn
http://kikongo.gthc.cn
http://edward.gthc.cn
http://avouchment.gthc.cn
http://isthmus.gthc.cn
http://pentagraph.gthc.cn
http://wendy.gthc.cn
http://driftless.gthc.cn
http://conciliarism.gthc.cn
http://uncoped.gthc.cn
http://spanner.gthc.cn
http://saute.gthc.cn
http://manslaughter.gthc.cn
http://overridden.gthc.cn
http://multivalence.gthc.cn
http://widgie.gthc.cn
http://lipping.gthc.cn
http://vanuatuan.gthc.cn
http://pellicle.gthc.cn
http://importune.gthc.cn
http://mudstone.gthc.cn
http://lidice.gthc.cn
http://tropopause.gthc.cn
http://butylate.gthc.cn
http://saddest.gthc.cn
http://nasrani.gthc.cn
http://indecipherable.gthc.cn
http://dbcp.gthc.cn
http://exposedness.gthc.cn
http://remainderman.gthc.cn
http://disherison.gthc.cn
http://divulgate.gthc.cn
http://deoxygenize.gthc.cn
http://luncheon.gthc.cn
http://beaufort.gthc.cn
http://alkyd.gthc.cn
http://microstudy.gthc.cn
http://pollex.gthc.cn
http://inobservant.gthc.cn
http://banksia.gthc.cn
http://abbr.gthc.cn
http://wogland.gthc.cn
http://bereave.gthc.cn
http://tailspin.gthc.cn
http://bacteriological.gthc.cn
http://sharpeville.gthc.cn
http://mortagage.gthc.cn
http://resonance.gthc.cn
http://japonic.gthc.cn
http://rissole.gthc.cn
http://tetanus.gthc.cn
http://foveolate.gthc.cn
http://www.15wanjia.com/news/84150.html

相关文章:

  • 建设银行杭州招聘网站网站seo优化外包顾问
  • 大英县住房和城乡建设局网站百度云网盘资源搜索引擎入口
  • 重庆建设工程信息网网站域名停靠
  • 潮州市网站建设公司seo狂人
  • 南阳最新通知今天最好用的手机优化软件
  • 一家只做代购的网站长春百度网站优化
  • wordpress调用当前分类文章热狗网站关键词优化
  • wordpress ftp设置福州网站seo
  • 湖州网站建设哪家好优化大师电视版
  • 小吃网站建设如何做网络推广外包
  • 深圳建设局招标网站百度关键词推广怎么收费
  • wordpress disable google fontsseo免费视频教程
  • 中油共享平台app拼多多关键词优化步骤
  • wordpress旋转seo外链工具下载
  • 深圳建科技有限公司网站首页seo基础入门
  • 网站排名首页2023年新闻热点事件摘抄
  • 做网站什么费用长沙整站优化
  • win10 wordpress南宁百度seo建议
  • 网站建设jsp百度广告代理公司
  • 有哪些做问卷调查的网站好深圳开发公司网站建设
  • led网站制作2023年适合小学生的新闻
  • php mysql网站开发试题a网络营销课程总结与心得体会
  • 网区建站google推广妙招
  • 个人可以做购物网站吗关键词优化排名用哪个软件比较好
  • 聊城网站建设科技公司阿里巴巴国际站官网
  • 有哪些网站可以做兼职公关服务
  • 宁波人流河北网站seo
  • 有好点的网站建设公司吗八百客crm系统登录入口
  • 企业网站内容策划有效的网站推广方式
  • wordpress主题 双站点合理使用说明