題目:給定兩個整數陣列,分別表示二元樹的前序遍歷和中序遍歷結果,請構造該二元樹並回傳其根節點。
範例:
前序遍歷 (preorder) = [3, 9, 20,...
A sentence consists of lowercase letters ('a' to 'z'), digits ('0' to '9'), hyph...
Problem :
Given the root of a binary tree, imagine yourself standing on the righ...
.call跟.apply 都可以直接呼叫函式並且改變函式內 this 的指向,兩者最主要的差異是傳入的參數形式不同。
.call
定義:.call 方法會立即...
You are given a 2D integer array ranges and two integers left and right. Each ra...
226. Invert Binary Tree
題目描述得非常簡單,給定一棵二元樹,你需要翻轉它,將左子樹與右子樹互換,輸出這棵樹翻轉後的結果。使用遞迴的解法:...