C++ | Inorder / Preorder / Postorder All 3 solution | 0ms faster than 100%
You can observe there is just a minimal diffrence in all 3 ,i.e, it\'s just the way of filling vector while calling fill function.  \nInorder Traversal : \n\ncl
You can observe there is just a minimal diffrence in all 3 ,i.e, it\'s just the way of filling vector while calling fill function.  \n***Inorder Traversal :*** \n```\nclass Solution {\npublic:\n    vector<int> ans;\n    void fill(TreeNode* root){\n        if(!root)\n            return;\n        fill(root->left);\n        ans.push_back(root->val);  // Inorder\n        fill(root->right);\n    }\n    \n    vector<int> inorderTraversal(TreeNode* root) {\n        fill(root);\n        return ans;\n    }\n};\n```\n\n***Preorder Traversal :***\n```\nclass Solution {\npublic:\n    vector<int> ans;\n    void fill(TreeNode* root){\n        if(!root)\n            return;\n        ans.push_back(root->val);  // Preoder\n        fill(root->left);\n        fill(root->right);\n    }\n    \n    vector<int> preorderTraversal(TreeNode* root) {\n        fill(root);\n        return ans;\n    }\n};\n```\n\n***Postorder Traversal :***\n\n```\nclass Solution {\npublic:\n    vector<int> ans;\n    void fill(TreeNode* root){\n        if(!root)\n            return;\n        fill(root->left);\n        fill(root->right);\n        ans.push_back(root->val);  /// Postorder\n    }\n    \n    vector<int> postorderTraversal(TreeNode* root) {\n        fill(root);\n        return ans;\n    }\n};\n```\nHope you liked it , kindly upvote !!\n\nHappy Coding \uD83E\uDD17
['Recursion', 'C', 'C++']