LeetCode OJ
Problems
Pick One!
Submissions
Sign up
Sign in
Convert Sorted Array to Binary Search Tree
AC Rate: 306/807
My Submissions
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.
C++
Java
/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ class Solution { public: TreeNode *sortedArrayToBST(vector<int> &num) { // Start typing your C/C++ solution below // DO NOT write int main() function } };
/** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ public class Solution { public TreeNode sortedArrayToBST(int[] num) { // Start typing your Java solution below // DO NOT write main() function } }
Submit Solution
You have not signed in, cannot submit your code.
Send Feedback