vector<<span style="color:blue">int> preorderTraversal(TreeNode *root) {
vector<<span style="color:blue">int> val_vector;
std::stack<<span style="color:blue">TreeNode*> my_stack;
while (root||!my_stack.empty())
{
if(root){
my_stack.push(root);
val_vector.push_back(root->val);
root=root->left;
}
else{
root=my_stack.top();
root=root->right;
my_stack.pop();
}
}
return val_vector;
}