From a2539333a0d798cba512b44dd47fc1abb7d89fbb Mon Sep 17 00:00:00 2001 From: Junwen Huang <58247686+hjwforever@users.noreply.github.com> Date: Thu, 12 Aug 2021 10:10:23 +0800 Subject: [PATCH] =?UTF-8?q?upt:=20edit=20=E4=BA=8C=E5=8F=89=E6=A0=91?= =?UTF-8?q?=E7=90=86=E8=AE=BA=E5=9F=BA=E7=A1=80.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加JavaScript版的二叉树节点定义方式 --- problems/二叉树理论基础.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/problems/二叉树理论基础.md b/problems/二叉树理论基础.md index abeeae67..edd1fed4 100644 --- a/problems/二叉树理论基础.md +++ b/problems/二叉树理论基础.md @@ -223,6 +223,14 @@ type TreeNode struct { } ``` +JavaScript: +``` +function TreeNode(val, left, right) { + this.val = (val===undefined ? 0 : val) + this.left = (left===undefined ? null : left) + this.right = (right===undefined ? null : right) +} +``` -----------------------