✅ Convert Sorted Array to Binary Search Tree || Easy Recursion
APPROACH:\nConstructing from sorted array in O(n) time is simpler as we can get the middle element in O(1) time. Following is a simple algorithm where we first 
# **APPROACH:**\nConstructing from sorted array in O(n) time is simpler as we can get the middle element in O(1) time. Following is a simple algorithm where we first find the middle node of list and make it root of the tree to be constructed. .\n\n**ALGORITHM:**\n1) Get the Middle of the array and make it root.\n2) Recursively do same for left half and right half.\n\t\t  a) Get the middle of left half and make it left child of the root created in step 1.\n\t\t  b) Get the middle of right half and make it right child of the root created in step 1.\n\n# **SOLUTION:**\n`In C++`\n```\n/**\n * Definition for a binary tree node.\n * struct TreeNode {\n *     int val;\n *     TreeNode *left;\n *     TreeNode *right;\n *     TreeNode() : val(0), left(nullptr), right(nullptr) {}\n *     TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n *     TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}\n * };\n */\nclass Solution {\npublic:\n    using it = vector<int>::const_iterator;\n    TreeNode* convert(it beg, it end) {\n        if (beg >= end) return nullptr;\n        \n        const auto mid = beg + (end - beg)/2;\n        return new TreeNode(*mid, convert(beg, mid), convert(mid+1, end));\n    }\n    TreeNode* sortedArrayToBST(vector<int>& nums) {\n        return convert(nums.cbegin(), nums.cend());\n    }\n};\n```\n`In Java`\n```\npublic TreeNode sortedArrayToBST(int[] nums, int si, int ei) {\n    if(si > ei)\n        return null;\n    int mid = (si + ei + 1) / 2;\n    TreeNode root = new TreeNode(nums[mid]);\n    root.left = sortedArrayToBST(nums, si, mid - 1);\n    root.right = sortedArrayToBST(nums, mid + 1, ei);\n    return root;\n}\n\npublic TreeNode sortedArrayToBST(int[] nums) {\n    return sortedArrayToBST(nums, 0, nums.length - 1);\n}\n```\n**TIME COMPLEXITY: O(N)**
['C', 'Java']