deno.land / x / masx200_leetcode_test@10.6.5 / symmetric-tree / index.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import { TreeNode } from "../binary-tree-inorder-traversal/TreeNode.ts";
export default function isSymmetric(root: TreeNode | null): boolean { return check(root, root);}function check(p: TreeNode | null, q: TreeNode | null): boolean { if (!p && !q) { return true; } if (!p || !q) { return false; } return p.val === q.val && check(p.left, q.right) && check(p.right, q.left);}
masx200_leetcode_test

Version Info

Tagged at
a year ago