/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* struct TreeNode *left;
* struct TreeNode *right;
* };
*/
struct TreeNode* build(int* nums,int head,int tail){
if(head>tail) return NULL;
int mid=head+(tail-head)/2;
struct TreeNode* root=(struct TreeNode*)malloc(sizeof(struct TreeNode));
root->val=nums[mid];
root->right=build(nums,mid+1,tail);
root->left=build(nums,head,mid-1);
return root;
}
struct TreeNode* sortedArrayToBST(int* nums, int numsSize) {
return build(nums,0,numsSize-1);
}
标签:head,TreeNode,struct,nums,int,二叉,108,数组,root
From: https://www.cnblogs.com/llllmz/p/18075221