A simple  C DFS solution
\n/**\n * Definition for a binary tree node.\n * struct TreeNode {\n *     int val;\n *     struct TreeNode *left;\n *     struct TreeNode *right;\n * };\n */\n
```\n/**\n * Definition for a binary tree node.\n * struct TreeNode {\n *     int val;\n *     struct TreeNode *left;\n *     struct TreeNode *right;\n * };\n */\n/**\n * Return an array of arrays of size *returnSize.\n * The sizes of the arrays are returned as *columnSizes array.\n * Note: Both returned array and *columnSizes array must be malloced, assume caller calls free().\n */\nint depthTree(struct TreeNode * root){\n    if(!root)\n        return 0 ;\n    int leftdepth = 1 + depthTree(root->left);\n    int rightdepth = 1+ depthTree(root->right);\n    \n    return leftdepth > rightdepth? leftdepth:rightdepth;\n}\n\nvoid getLevelVal(int ** levelArr, struct TreeNode* root, int* columnSizes, int level){\n    \n    if(root == NULL){\n        return ;\n    }\n    columnSizes[level]++;\n    levelArr[level] = (int *)realloc(levelArr[level], columnSizes[level]*sizeof(int));\n    levelArr[level][columnSizes[level] - 1] = root->val;\n        \n    \n    getLevelVal(levelArr, root->left, columnSizes, level+1);\n    getLevelVal(levelArr, root->right, columnSizes, level+1);\n}\n\nint** levelOrder(struct TreeNode* root, int** columnSizes, int* returnSize) {\n    \n    if(!root)\n        return NULL;\n    *returnSize = depthTree(root);\n    int ** levelArr = (int **)calloc(*returnSize, sizeof(int*));\n    *columnSizes = (int *)calloc(*returnSize, sizeof(int));\n    getLevelVal(levelArr, root, *columnSizes, 0);\n    \n    return levelArr;\n}\n```
[]