leetcode 94. Binary Tree Inorder Traversal

Posted zhangwj0101

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了leetcode 94. Binary Tree Inorder Traversal相关的知识,希望对你有一定的参考价值。

Question

Given a binary tree, return the inorder traversal of its nodes’ values.

For example:
Given binary tree 1,#,2,3,

  1
    \\
     2
    /
   3

return [1,3,2].

Code

 public void get(TreeNode root, List<Integer> results) 
        if (root == null) 
            return;
        
        get(root.left, results);
        results.add(root.val);
        get(root.right, results);
    

    public List<Integer> inorderTraversal(TreeNode root) 
        List<Integer> results = new ArrayList<>();
        get(root, results);
        return results;
    

以上是关于leetcode 94. Binary Tree Inorder Traversal的主要内容,如果未能解决你的问题,请参考以下文章

[leetcode-94-Binary Tree Inorder Traversal]

[LeetCode]94.Binary Tree Inorder Traversal

leetcode 94. Binary Tree Inorder Traversal

LeetCode94 Binary Tree Inorder Traversal

LeetCode 94. Binary Tree Inorder Traversal

LeetCode 94: Binary Tree Inorder Traversal