<commit_before>#include<iostream>
#include<vector>
using namespace std;

struct TreeNode {
    int val;
    TreeNode *left;
    TreeNode *right;
    TreeNode(int x) : val(x), left(NULL), right(NULL) {}
};

void createBST(TreeNode * root, vector<int> &num, int start, int end);
TreeNode *sortedArrayToBST(vector<int> &num);

TreeNode *sortedArrayToBST(vector<int> &num) {
    if(num.size() == 0) return NULL;
    int start = 0, end = num.size() - 1;
    TreeNode * root = NULL;
    createBST(root, num, start, end);
    return root;
}

void createBST(TreeNode * root, vector<int> &num, int start, int end){
    if(start > end) return;
    int mid = start - (start - end)/2;
    root = new TreeNode(num[mid]);
    createBST(root->left, num, 0, mid-1);
    createBST(root->right, num, mid+1, end);
}

int main(){
    int a[] = {1, 2, 3, 4, 5, 6};
    vector<int> num(a, a+6);
    TreeNode * root = sortedArrayToBST(num);
}<commit_msg>bug fixed and accepted by OJ<commit_after>class Solution {
    public:
        TreeNode *sortedArrayToBST(vector<int> &num) {
            if(num.size() == 0) return NULL;
            int start = 0, end = num.size() - 1;
            TreeNode * root = createBST(num, start, end);
            return root;
        }

        TreeNode * createBST(vector<int> &num, int start, int end){
            if(start > end) return NULL;
            int mid = start - (start - end)/2;
            TreeNode * root = new TreeNode(num[mid]);
            root->left = createBST(num, start, mid-1);
            root->right = createBST(num, mid+1, end);
            return root;
        }
};
{'fraction_non_alphanumeric': 0.15053091817613992, 'fraction_numerical': 0.012492192379762648, 'mean_word_length': 2.6, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '520210', 'n_tokens_mistral': 569, 'n_tokens_neox': 554, 'n_words': 154}