✅ Easiest TypeScript Solution Image&Explanation+ (Beautiful 4 BFS Liners)
\n# Code (Beautiful 4 BFS Liners)\n- Gets the number, and if it has the length of 0, obviously should return null.\n- Get the center index of given array. n / 2
\n# Code (Beautiful 4 BFS Liners)\n- Gets the number, and if it has the length of `0`, obviously should return `null`.\n- Get the center index of given array. `n / 2` will be chosen when `n` is even number.\n- Set the center index as a center of the node, and the array to the left will be sent to `sortedArrayToBST()` recursively, and vice versa for the right side.\n    - This logic works, with the following diagram\n    - Only the left-most logic was drawn, but the rest follow the same logic.\n![image.png](https://assets.leetcode.com/users/images/ce590f5f-ae34-42ce-86f2-e20a1b98c8c4_1679090669.4754777.png)\n![image.png](https://assets.leetcode.com/users/images/36038513-f1a7-4999-b8ef-b10f883452bc_1679090677.5556152.png)\n![image.png](https://assets.leetcode.com/users/images/f55c9c47-4681-4d2b-8235-96f2e402b871_1679090689.560499.png)\n![image.png](https://assets.leetcode.com/users/images/b26c28c5-74e3-4986-9c89-8ed6e79b002d_1679090694.91906.png)\n![image.png](https://assets.leetcode.com/users/images/7bc828c8-7284-4660-b6d5-298c92147e1f_1679090700.6244662.png)\n![image.png](https://assets.leetcode.com/users/images/b02f44fe-cd76-4736-8c2f-86299e069442_1679090706.4978616.png)\n\n*end.*\n\n```\nfunction sortedArrayToBST(nums: number[]): TreeNode | null {\n    if (nums.length === 0) return null\n\n    const centerIndex = Math.floor(nums.length / 2)\n    return new TreeNode(nums[centerIndex],\n        sortedArrayToBST(nums.slice(0, centerIndex)),\n        sortedArrayToBST(nums.slice(centerIndex + 1))\n    )\n};\n```\n\n## Tips\n- If you face such a problem like this, its the best to reuse the given function most of the times.
['TypeScript']