✅Short || C++ || Java || PYTHON || Explained Solution✔️ || Beginner Friendly ||🔥 🔥 BY MR CODER
Please UPVOTE if you LIKE!!\nWatch this video \uD83E\uDC83 for the better explanation of the code.\n\nhttps://www.youtube.com/watch?v=cIaijn-ovLE&t=353s\n\n\nAl
**Please UPVOTE if you LIKE!!**\n**Watch this video \uD83E\uDC83 for the better explanation of the code.**\n\nhttps://www.youtube.com/watch?v=cIaijn-ovLE&t=353s\n\n\n**Also you can SUBSCRIBE  \uD83E\uDC81 \uD83E\uDC81 \uD83E\uDC81 this channel for the daily leetcode challange solution.**\n**C++**\n```\nTreeNode* convertintoBST(vector nums,int left,int right)\n{\n\n//Base Case\nif(left > right) return NULL;\n//find mid\nint mid = left+(right-left)/2;\n//create Node\nTreeNode node = new TreeNode(nums[mid]);\n//create LEFT CHILD\n node->left = convertintoBST(nums,left,mid-1);\n//create LEFT CHILD\nnode->right = convertintoBST(nums,mid+1,right);\n\nreturn node;}\nTreeNode* sortedArrayToBST(vector<int>& nums) {\nif(nums.size() == 0) return NULL;\nreturn convertintoBST(nums,0,nums.size()-1);\n}\n\nJAVA\nclass Solution {\n\npublic TreeNode sortedArrayToBST(int[] nums) {\n    return helper_binaryBuilder(nums,0, nums.length-1) ;\n}\n\nprivate TreeNode helper_binaryBuilder(int[] nums, int left, int right){\n    if (left > right) return null;\n    int m = (right + left) / 2;\n    TreeNode root = new TreeNode(nums[m]);\n    root.left = helper_binaryBuilder(nums, left, m - 1);\n    root.right = helper_binaryBuilder(nums, m + 1, right);\n    return root;\n}\n}\n```\n**PYTHON**\n```\nclass Solution:\n    def sortedArrayToBST(self, nums: List[int]) -> Optional[TreeNode]:\n        total_nums = len(nums)\n        if not total_nums:\n            return None\n\n        mid_node = total_nums // 2\n        return TreeNode(\n            nums[mid_node], \n            self.sortedArrayToBST(nums[:mid_node]), self.sortedArrayToBST(nums[mid_node + 1 :])\n        )\n```\n**Please do UPVOTE to motivate me to solve more daily challenges like this !!**
['C', 'Java']