標籤:leetcode java validate binary sear 題目:Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes
標籤:leetcode java recover binary searc 題目:Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A solution using O(n) space is pretty
標籤:leetcode java symmetric tree 題目: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
標籤:leetcode java binary tree level or 題目: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
標籤:leetcode java binary tree zigzag l 題目:Given a binary tree, return the zigzag level order traversal of its nodes‘ values. (ie, from left to right, then right to left for the next level
標籤:第1條:考慮用靜態Factory 方法代替構造器【尚未徹底讀懂筆者的意圖】 第2條:遇到多個構造器參數時要考慮用構造器1.使用重疊構造器:缺點是寫太多2.使用JavaBean模式:缺點是不一致3.使用Builder模式:先創造構造器,太冗長Builder模式: 1 public class NutritionFacts{ 2 private final int servingSize; 3 private final int servings; 4