Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Binary Tree Preorder Traversal Solution for C++ (https://leetcode.com/problems/binary-tree-preorder-traversal/)
Pull Request Template
Description
Problem Summary:
Given the root of a binary tree, return the preorder traversal of its nodes' values.
Example:
Input: root = [1, null,2,3]
Output: [1,2,3]
Constraints:
Approach to the Problem:
In the problem description, it was asked to try to solve the problem iteratively. To be able to do that, using a stack was the best way to solve it. The first step was to evaluate if the given input was an empty vector. If it's empty, return the empty stack. Another case to check for is making sure that the preorder traversal is correct. Preorder Traversal is visiting the root first, then the left subtree, and finally the right subtree is traversed.
List any dependencies that are required for this change.
Put check marks:
Have you made changes in README file ?
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Please also note any relevant details for your test configuration.
Input
root = [1,null,2,3]
Output
[1,2,3]
Expected
[1,2,3]
Input
root = [ ]
Output
[ ]
Expected
[ ]
Make sure all below guidelines are followed else PR will get Reject: