Definition at line 21 of file main.cpp.
◆ inorderTraversal()
| vector< int > Solution::inorderTraversal |
( |
TreeNode * |
root | ) |
|
|
inline |
Definition at line 24 of file main.cpp.
25 {
26 vector<int> answer = {};
27 stack<TreeNode*> node_stack;
29
30 while (current != nullptr || !node_stack.empty())
31 {
32 while (current != nullptr)
33 {
34 node_stack.push(current);
35 current = current->
left;
36 }
37 current = node_stack.top();
38 node_stack.pop();
39 answer.push_back(current->
val);
40 current = current->
right;
41 }
42
43 return answer;
44 }
Definition for a binary tree node.
References TreeNode::left, TreeNode::right, and TreeNode::val.
Referenced by main().
The documentation for this class was generated from the following file: