means? > read more on how binary tree is serialized on OJ.
The above binary tree is serialized as ./** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */class Solution {public: vector<TreeNode *> generate(int left, int right) {vector<TreeNode *> res;if(left>right)return res;if(left == right){res.push_back(new TreeNode(left));return res;}for(int r = left; r <= right; r++){vector<TreeNode*> lchild;vector<TreeNode*> rchild;if(r==left){rchild = generate(left+1,right);for(int i =0; i< rchild.size(); i++){TreeNode* root = new TreeNode(r);root->right = rchild[i];res.push_back(root);}}else if(r == right){lchild = generate(left, right-1);for(int i = 0; i < lchild.size(); i++){TreeNode* root = new TreeNode(r);root->left = lchild[i];res.push_back(root);}}else{lchild = generate(left,r-1);rchild = generate(r+1,right);for(int i = 0; i < lchild.size(); i++){for(int j = 0; j <rchild.size(); j++){TreeNode* root = new TreeNode(r);root->left = lchild[i];root->right = rchild[j];res.push_back(root);}}}}return res;}vector<TreeNode *> generateTrees(int n) { // Note: The Solution object is instantiated only once. if(n<1){vector<TreeNode*> res;TreeNode * tmp =NULL;res.push_back(tmp);return res;} return generate(1,n); }};