标签:return leetcode class problem etc tco str node efi
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
public:
vector<int> inorderTraversal(TreeNode* root) {
vector<int> ans;
stack<TreeNode*> stk;
while (root || stk.size()) {
while (root) {
stk.push(root);
root = root->left;
}
root = stk.top();
stk.pop();
ans.push_back(root->val);
root = root->right;
}
return ans;
}
};
标签:return leetcode class problem etc tco str node efi
原文地址:https://www.cnblogs.com/clown9804/p/13334526.html