← Goldman Sachs questions
CodingReported in a candidate post, Sep 2025

Count unconnected trees and the root with most children

Filed under Goldman Sachs

You are given child-to-parent pairs describing a forest of rooted trees. Return the number of separate (unconnected) trees and the root of the tree with the most nodes. (The report says 'most…

You've read your 3 free write-ups

Sign up free to keep reading. Your account opens the first 10 questions of every company.

Related Goldman Sachs questions

Collected from public candidate posts and coding forums. Updated Nov 2026.