Tree

Asked atAAugnitoExpediaMeeshoMicrosoftTSTechMojo Solutions
1Give yourself 5 minutes
2Answer out loud, not in your head
3Then compare with the answer below
0
Stuck? Show a way to structure it+
  1. 01Ask for the required output and tree type.
  2. 02Choose DFS or BFS to match the requested order or property.
  3. 03State the per-node invariant or returned value.
  4. 04Cover null root and skewed depth.

Reference answer

Then expect these follow-ups

  • When is BFS preferable to DFS?

    Tests: traversal choice

  • How do you validate that an input is a tree?

    Tests: graphs

Hiring now

Expedia has 109 open roles right now

Also hiring: Meesho

landed applies to roles like these for you, on each company’s own site, with answers written for the role.

Get 5x interviews10 free auto-applies. No card.
  • Technical Program Manager III, AI & Data

    India - Gurgaon

  • Solution Engineer

    UK - London

  • Senior Business Programs Manager, Expedia Voices

    USA - Illinois - Chicago

Or practice this question first

Next question