/*struct TreeNode {
int val;
struct TreeNode *left;
struct TreeNode *right;
};*/
int count;
struct TreeNode* Order(struct TreeNode* root,int j , int* * returnColumnSizes, int** nums){
if(!root)
return NULL;
nums[j][returnColumnSizes[0][j]++] = root->val;
if(j+1 > count)
count = j + 1;
root->left = Order(root->left, j+1, returnColumnSizes, nums);
root->right = Order(root->right, j+1,returnColumnSizes,nums);
return root;
}
int** levelOrder(struct TreeNode* root, int* returnSize, int** returnColumnSizes){
if(!root){
* returnSize = 0;
return NULL;
}
count = 0;
int** nums = (int** )malloc(sizeof(int* )*1000);
for(int k=0; k<1000; k++){
nums[k] = (int* )calloc(129, sizeof(int));
}
returnColumnSizes[0] = (int*)calloc(1000, sizeof(int));
struct TreeNode* p = Order(root, 0, returnColumnSizes, nums);
*returnSize = count;
return nums;
}