← Questions

Serialize and deserialize a binary tree

0
AppleAmazonCodingLast asked Nov 2026

A coding interview question asked in Amazon's technical phone screen and at Apple, last asked Nov 2026. It tests trees, bfs and dfs.

Write two functions for a binary tree of integer values: encode turns a tree into a string, and decode rebuilds a tree with exactly the same structure and values from that string. You choose the format, but it must be deterministic and…

Sign in to unlock this question

The full prompt, the worked answer and your own canvas or code with the AI tutor. New accounts get 5 credits: each one unlocks a question for good.

Where it's asked

  • Amazon · Technical phone screen · Last asked Nov 202660 min · Live coding in a shared editor that does not run code, plus Leadership Principles questions · No AI
  • Apple · Technical phone screen · Last asked Apr 2026

What it tests

trees · bfs · dfs · encoding

Your code and the AI tutor open when you unlock this question.