C++ recursive simple solution || 0 ms, 100% faster
C++ :\n\n\nvoid preorderTraversalHelper(TreeNode* root, vector<int> &res) {\n\tif(root)\n\t{\n\t\tres.push_back(root -> val);           \n\n\t\tif(root -> left)
**C++ :**\n\n```\nvoid preorderTraversalHelper(TreeNode* root, vector<int> &res) {\n\tif(root)\n\t{\n\t\tres.push_back(root -> val);           \n\n\t\tif(root -> left)\n\t\t\tpreorderTraversalHelper(root -> left, res);\n\n\t\tif(root -> right)\n\t\t\tpreorderTraversalHelper(root -> right, res);\n\t}\n\n\treturn;\n}\n\n\nvector<int> preorderTraversal(TreeNode* root) \n{   \n\tvector<int> res;\n\tpreorderTraversalHelper(root, res) ;\n\treturn res;\n}\n```\n\n**Like it ? please upvote !**
['Recursion', 'C', 'C++']