連三天都是easy爛題是怎樣 = =
https://leetcode.com/problems/binary-tree-inorder-traversal/
這個我就跳過解釋直接付code
class Solution {
public:
vector<int> inorderTraversal(TreeNode* root) {
vector<int> output;
stack<TreeNode*> temp;
TreeNode* cur = root;
while (!temp.empty() || cur) {
while (cur) {
temp.push(cur);
cur = cur->left;
}
cur = temp.top();
temp.pop();
output.push_back(cur->val);
cur = cur->right;
}
return output;
}
};