Skip to content

Latest commit

 

History

History
21 lines (17 loc) · 342 Bytes

File metadata and controls

21 lines (17 loc) · 342 Bytes

樹 (Tree)

二元樹 (Binary Tree)

class TreeNode<T> {
  val: T;
  left: TreeNode<T> | null;
  right: TreeNode<T> | null;

  constructor(val: T, left: TreeNode<T> | null = null, right: TreeNode<T> | null = null) {
    this.val = val;
    this.left = left;
    this.right = right;
  }
}
const n1 = new TreeNode(1);