deno.land / x / masx200_leetcode_test@10.6.5 / convert-sorted-array-to-binary-search-tree / index.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import { buildBST } from "../convert-sorted-list-to-binary-search-tree/buildBST.ts";import { TreeNode } from "../mod.ts";
export default function sortedArrayToBST(nums: number[]): TreeNode | null { if (nums.length === 0) return null; const n = nums.length; let index = 0;
return buildBST( 0, n - 1, () => nums[index], () => { if (index >= n) return;
index++; }, );}
masx200_leetcode_test

Version Info

Tagged at
a year ago