Loading problem…
Given the root of a binary tree, return the inorder traversal of its nodes' values.
Example 1
Input: root = [1,null,2,3]
Output: [1,3,2]
Explanation: Inorder visits left subtree, node, right subtree. Node 1 has no left child, so 1 comes first. Its right child 2 has a left child 3, so 3 is visited before 2, giving [1,3,2].
Example 2
Input: root = []
Output: []
Explanation: The tree is empty, so there is nothing to visit.
Example 3
Input: root = [1]
Output: [1]
Explanation: The only node is visited, giving [1].
Inorder visits the left subtree, then the node, then the right subtree — for a BST this yields sorted order.
Run checks all cases above. Submit evaluates all test cases.