I did it myself somehow but don't know how it works 😅 is it something like reverse of preorder? class Solution { public: vector postorderTraversal(TreeNode* root) { vector res; stack st; if(root==NULL)return res; st.push(root); while(!st.empty()){ TreeNode* node = st.top(); st.pop(); if(node->left!=nullptr) st.push(node->left); if(node->right!=nullptr){ st.push(node->right); } res.push_back(node->val); } reverse(res.begin(), res.end()); return res; } };