题目

代码
class Solution {
public List<Integer> inorderTraversal(TreeNode root) {
LinkedList<Integer> res = new LinkedList();
Stack<TreeNode> stack = new Stack();
while(root != null || !stack.isEmpty()){
while(root!=null) {
stack.add(root);
root = root.left;
}
root = stack.pop();
res.add(root.val);
root = root.right;
}return res;
}
}
结果


516

被折叠的 条评论
为什么被折叠?



