LeetCode,leetcodeoj題目:Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \3 4 4 3 But the following is not: 1 / \ 2 2 \ \ 3
LeetCode,leetcodeoj題目:Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example:Given binary tree {3,9,20,#,#,15,7}, 3 / \ 9 20 / \ 15 7 return its level order
LeetCode,leetcodeoj題目:Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.思路:遞迴,preorder的第一個元素必然是根節點package treetraversal;public class
LeetCode,leetcodeoj題目:Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root). For example:Given binary tree {3,9,20,#,#,15,7}, 3 / \ 9 20 / \ 15
[javase學習筆記]-7.14 靜態代碼塊這一節我們看一個比較特殊的概念,那就是靜態代碼塊。 前面我們也提到過代碼塊,就是一段獨立的代碼空間,那麼什麼是靜態代碼塊呢?說白了,就是用static關鍵字修飾的代碼塊。我們來看一個例子: class StaticBlock{static{System.out.println("靜態代碼塊被執行");}void
LeetCode,leetcodeoj題目:Given an array where elements are sorted in ascending order, convert it to a height balanced BST.思路:總是取中間點為rootpackage bst;public class ConvertSortedArrayToBinarySearchTree { public TreeNode sortedArrayToBST(int[] nums) {
java自動裝箱拆箱總結對於java1.5引入的自動裝箱拆箱,之前只是知道一點點,最近在看一篇部落格時發現自己對自動裝箱拆箱這個特性瞭解的太少了,所以今天研究了下這個特性。以下是結合測試代碼進行的總結。測試代碼: int a = 1; Integer b = 1; Integer c = 1; Integer d = 2; Integer e = 3; Integer f = 128;
從頭認識java-17.2 基本的線程機制(1)-初識多線程-2接著上一個章節,我們這一章節介紹一下多線程的注意點。線程間執行的順序和時間是不同的我們修改一下上一章節的代碼: package com.ray.ch17;public class Test {public static void main(String[] args) {for (int i = 5; i < 8; i++) {DoneMission doneMission = new DoneMission(i);