leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

0590.cpp (447B)


0 class Solution {
1 public:
2 vector<int> postorder(Node *root) {
3 if (!root) return {};
4 vector<int> res;
5 stack<Node *> st;
6 st.push(root);
7 while (!st.empty()) {
8 Node *root = st.top();
9 st.pop();
10 for (Node *c : root->children)
11 st.push(c);
12 res.push_back(root->val);
13 }
14 reverse(res.begin(), res.end());
15 return res;
16 }
17 };