Back to the 100
Problem 094Trees
Hard

Serialize and Deserialize Binary Tree

094

Given a binary tree encoded as level-order with -100000 as null, return the canonical serialized level-order encoding after deserialize/serialize.

EXAMPLES

Example 1
Input
{
  "root": [
    1,
    2,
    3,
    -100000,
    -100000,
    4,
    5
  ]
}

Output
[
  1,
  2,
  3,
  -100000,
  -100000,
  4,
  5
]

FUNCTION SHAPE

root: intArrayintArray
00:00
2 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.