A Java solution, beats 96.48%

  • 0
    public class Solution {
        public List<Integer> inorderTraversal(TreeNode root) {
            List<Integer> res = new ArrayList<>();
            inorderTraver(root, res);
            return res;
        public void inorderTraver(TreeNode root, List<Integer> res) {
            if (root == null) return;
            inorderTraver(root.left, res);
            inorderTraver(root.right, res);

  • 2

    didn't the problem state that no recursion!

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.