class Solution {

public:

void myLevelOrder(TreeNode* root, int level)

{

```
if(res.size()<=level)
res.push_back(vector<int>());
res[level].push_back(root->val);
if(root->left) myLevelOrder(root->left, level+1);
if(root->right) myLevelOrder(root->right, level+1);
}
vector<vector<int>> levelOrderBottom(TreeNode* root) {
if(!root) return res;
myLevelOrder(root, 0);
reverse(res.begin(),res.end());
return res;
}
```

private:

vector<vector<int>> res;

};