Very easy title, at the back, I don't think it's so simple to answer more. We will write, no one.
Pre-order on the ground floor, plus save every layer, plus the output from the bottom up, is a vector and a stack so the problem, without him, but on the other hand-cooked Seoul.
Class Solution {public:vector<vector<int> > Levelorderbottom (TreeNode *root) {vector<vector< int> > Res; if (root = NULL) return res; Queue<treenode*> que; stack<vector<int> > S; Vector<int> Tpres; TreeNode *pnode; Que.push (root); Que.push (NULL); while (!que.empty ()) {Pnode = Que.front (); Que.pop (); if (Pnode = = NULL) {s.push (tpres); Tpres.clear (); if (Que.empty ()) break; else{Que.push (NULL); Continue }} tpres.push_back (Pnode->val); if (pnode->left) Que.push (pnode->left); if (pnode->right) Que.push (pnode->right); } while (!s.empty ()) {Res.push_back (S.top ()); S.pop (); } return Res; }};
Leetcode First brush _binary Tree level Order traversal II