Back to the 100
Problem 077Trees
Medium

Binary Search Tree Iterator

077

Given a BST encoded as level-order with -100000 as null, return all next() values from a BST iterator.

EXAMPLES

Example 1
Input
{
  "root": [
    7,
    3,
    15,
    -100000,
    -100000,
    9,
    20
  ]
}

Output
[
  3,
  7,
  9,
  15,
  20
]

FUNCTION SHAPE

root: intArrayintArray
00:00
1 local tests readyRun with ⌘/Ctrl + Enter. Your code stays in this browser.

Runs solve(...) locally in a browser worker. SWE Playbook does not submit your code. Only run code you trust; Python code may access the network.