国产亚洲精品福利在线无卡一,国产精久久一区二区三区,亚洲精品无码国模,精品久久久久久无码专区不卡

當(dāng)前位置: 首頁 > news >正文

中國網(wǎng)頁設(shè)計師網(wǎng)站代運(yùn)營靠譜嗎

中國網(wǎng)頁設(shè)計師網(wǎng)站,代運(yùn)營靠譜嗎,做公司網(wǎng)站哪家好,科技素材目錄 模版 先序遍歷 中序遍歷 后序遍歷 力扣原題 相同的二叉樹 力扣原題 翻轉(zhuǎn)二叉樹 遍歷樹的層數(shù) 題目 靜態(tài)變量 核心邏輯 模版 // 二叉樹public static class Node{public int value;public Node left;public Node right;public Node(int v) {valuev;}} 先序遍歷 …

目錄

模版

先序遍歷

中序遍歷

后序遍歷

力扣原題 相同的二叉樹

力扣原題 翻轉(zhuǎn)二叉樹

遍歷樹的層數(shù)

題目

靜態(tài)變量

核心邏輯


模版

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

先序遍歷

根節(jié)點(diǎn) 左孩子節(jié)點(diǎn) 右孩子節(jié)點(diǎn)

中序遍歷

左孩子節(jié)點(diǎn) 根節(jié)點(diǎn) 右孩子節(jié)點(diǎn)

后序遍歷

左孩子節(jié)點(diǎn) 右孩子節(jié)點(diǎn) 根節(jié)點(diǎn)

力扣原題 相同的二叉樹

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);}
}

力扣原題 翻轉(zhuǎn)二叉樹

/*** 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;}
}

遍歷樹的層數(shù)

題目

靜態(tài)變量

核心邏輯

import java.util.*;
import java.math.*;
import java.time.*;
import java.io.*;
import java.util.regex.*;// Eclipse IDE 2020 08
// OpenJDK 1.8
// 下方網(wǎng)頁是個人主頁
// http://gczdy.cn/*.-'''-.     
_______     _______               '   _    \   
\  ___ `'.  \  ___ `'.          /   /` '.   \  ' |--.\  \  ' |--.\  \        .   |     \  '  | |    \  ' | |    \  '       |   '      |  ' | |     |  '| |     |  '      \    \     / /  | |     |  || |     |  | _    _`.   ` ..' /   | |     ' .'| |     ' .'| '  / |  '-...-'`    | |___.' /' | |___.' /'.' | .' |              
/_______.'/ /_______.'/ /  | /  |              
\_______|/  \_______|/ |   `'.  |              '   .'|  '/             `-'  `--'              
*//*** * @Author Dduo* @Date 2025-01-10*/
public class Main {//    普通流
//    static Scanner sc = new Scanner(System.in);//    數(shù)據(jù)流快讀模板(類似于C++的IOS)static Read sc=new Read();//    時間類 用來測試運(yùn)行時間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();//      預(yù)處理preconditioning();while (t-- > 0) {solve();}//   	 	sc.close();
//			dduoln("運(yùn)行時間 : "+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);}//  預(yù)處理static void preconditioning() {}//    數(shù)據(jù)結(jié)構(gòu)模板 二叉樹 by Dduostatic class Node{public int value;public Node left;public Node right;public Node() {}public Node(int v) {value=v;}}//    靜態(tài)變量static Node[] a = new Node[1000010];static int cnt=0;//    核心代碼邏輯static void solve() throws Exception { 	// 構(gòu)造二叉樹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);// 判斷當(dāng)前節(jié)點(diǎn)是否是葉子節(jié)點(diǎn)(即左右子節(jié)點(diǎn)都為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;}}
}// 數(shù)據(jù)結(jié)構(gòu)模版 并查集 by Dduo
class UnionFind {private int[] parent;private int[] size;// 初始化并查集public UnionFind(int n) {parent = new int[n + 1]; // 因?yàn)榫幪枏?1 到 N,所以數(shù)組大小是 N+1size = new int[n + 1];for (int i = 1; i <= n; i++) {parent[i] = i; // 每個元素的父節(jié)點(diǎn)初始為自己size[i] = 1;   // 每個元素的初始大小為 1}}// 查找元素 x 所在的集合,帶路徑壓縮優(yōu)化public int find(int x) {if (parent[x] != x) {parent[x] = find(parent[x]);  // 路徑壓縮}return parent[x];}// 合并兩個集合 帶按秩合并優(yōu)化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);}
}// 數(shù)據(jù)流快讀模板(類似于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;}
//    其他調(diào)試命令:public void flush() throws IOException{
//      交互題分組調(diào)試,或者提前退出的情況下可以先運(yùn)行此語句再推出bw.flush();return;}public boolean hasNext() throws IOException{
//      本地普通IDE難以使用這個方法調(diào)試,需要按照數(shù)據(jù)組flush,刷新語句:
//      sc.flush()
//      調(diào)試完可刪去return bf.ready();}
}
http://m.aloenet.com.cn/news/29511.html

相關(guān)文章:

  • 銷售員做網(wǎng)站常德網(wǎng)站seo
  • 速賣通網(wǎng)站怎么做推廣seo具體優(yōu)化流程
  • 定制網(wǎng)站建設(shè)公司怎么在百度上發(fā)布廣告
  • 做網(wǎng)站造假國內(nèi)免費(fèi)推廣產(chǎn)品的網(wǎng)站
  • 和網(wǎng)站建設(shè)簽合同2020 惠州seo服務(wù)
  • 360網(wǎng)站賣東西怎么做搜索引擎優(yōu)化seo培訓(xùn)
  • 做企業(yè)網(wǎng)站必須要座機(jī)嗎聯(lián)盟營銷平臺
  • 跨境電商獨(dú)立站運(yùn)營百度一下的網(wǎng)址
  • 深圳制作網(wǎng)站培訓(xùn)學(xué)校陜西seo快速排名
  • 網(wǎng)站開發(fā)網(wǎng)站設(shè)計案例免費(fèi)推廣工具有哪些
  • 網(wǎng)站用哪些系統(tǒng)做的比較好用如何網(wǎng)站推廣
  • 事件營銷方案模板寧波seo外包公司
  • 網(wǎng)站建設(shè)新趨勢國內(nèi)新聞大事
  • 樹形菜單的網(wǎng)站代碼網(wǎng)絡(luò)運(yùn)營推廣具體做什么工作
  • 做門戶類網(wǎng)站報價上海疫情又要爆發(fā)了
  • 網(wǎng)站服務(wù)器租用有什么好學(xué)大教育一對一收費(fèi)價格表
  • 郴州企業(yè)網(wǎng)站建設(shè)制作營銷案例100例
  • 網(wǎng)站建站建設(shè)網(wǎng)站中國企業(yè)500強(qiáng)排行榜
  • a0000網(wǎng)站建設(shè)2022年seo最新優(yōu)化策略
  • 博山網(wǎng)站建設(shè)網(wǎng)頁制作基礎(chǔ)教程
  • 四川城鄉(xiāng)住房建設(shè)廳官方網(wǎng)站seo搜索優(yōu)化公司排名
  • 新華社官網(wǎng)百度推廣怎么優(yōu)化
  • 深圳平湖網(wǎng)站建設(shè)有免費(fèi)推廣平臺
  • 東莞網(wǎng)站推廣優(yōu)化建設(shè)seo站長工具
  • 吳橋縣網(wǎng)站建設(shè)價格沈陽頭條今日頭條新聞最新消息
  • 網(wǎng)站做分站360收錄批量查詢
  • 多少網(wǎng)站域名采用中文四川全網(wǎng)推網(wǎng)絡(luò)推廣
  • 服務(wù)器的做網(wǎng)站空間北京疫情最新新聞
  • 重慶網(wǎng)站建設(shè)最大seo自然排名關(guān)鍵詞來源的優(yōu)缺點(diǎn)
  • 赤峰做網(wǎng)站的公司鄭州seo優(yōu)化顧問熱狗