C++ Solution || 100% faster || Iterative Solution
\nclass Solution {\npublic:\n    vector<int> preorderTraversal(TreeNode* root) {\n        vector<int> preorder;\n        stack<TreeNode*> stack;\n        if (ro
```\nclass Solution {\npublic:\n    vector<int> preorderTraversal(TreeNode* root) {\n        vector<int> preorder;\n        stack<TreeNode*> stack;\n        if (root == NULL)\n            return preorder;\n        stack.push(root);\n        while(!stack.empty()) {\n            TreeNode* curr = stack.top();\n            stack.pop();\n            preorder.push_back(curr->val);\n            if (curr->right != NULL)\n                stack.push(curr->right);\n            if (curr->left != NULL)\n                stack.push(curr->left);\n        }\n        return preorder;\n    }\n};\n```
['Stack', 'C', 'Iterator', 'C++']