Goldman Sachs logoGoldman Sachs
CodingMembers

Largest Tree in a Forest

Members only

Goldman Sachs SDE CoderPad phone screen built on a forest encoded as a child-to-parent map: find the root of the tree that holds the most nodes, with a deterministic tie-break when sizes match. The trick is correctly distinguishing roots from inner nodes and aggregating each tree's size in a single linear scan — a brisk round that rewards a clean, complexity-aware solution.

SWE
tree
bfs
hashmap
medium
Frequency
Low
Last asked
2026-10-06
Stage
phone-screen

Members get

  • Full problem statement
  • Known variants to clarify
  • Step-by-step approach
  • 2 common pitfalls
  • Preparation drills

Log in to continue reading the full content

Comments

Sign in to join the discussion
Loading...