From de37c44f4fbc6b368f1afe6a51e508c949ff9271 Mon Sep 17 00:00:00 2001 From: Steve2020 <841532108@qq.com> Date: Mon, 24 Jan 2022 19:41:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=EF=BC=88=E4=BA=8C=E5=8F=89?= =?UTF-8?q?=E6=A0=91=E7=90=86=E8=AE=BA=E5=9F=BA=E7=A1=80.md=EF=BC=89?= =?UTF-8?q?=EF=BC=9A=E5=A2=9E=E5=8A=A0typescript=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problems/二叉树理论基础.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/problems/二叉树理论基础.md b/problems/二叉树理论基础.md index cc899850..009e8276 100644 --- a/problems/二叉树理论基础.md +++ b/problems/二叉树理论基础.md @@ -227,7 +227,23 @@ function TreeNode(val, left, right) { } ``` +TypeScript: + +```typescript +class TreeNode { + public val: number; + public left: TreeNode | null; + public right: TreeNode | null; + constructor(val?: number, left?: TreeNode, right?: TreeNode) { + this.val = val === undefined ? 0 : val; + this.left = left === undefined ? null : left; + this.right = right === undefined ? null : right; + } +} +``` + Swift: + ```Swift class TreeNode { var value: T