Giving Tree of Errors: Validate Parent-Child Pairs and Output Lexicographically Smallest S-Expression

You are given an unordered list of parent-child pairs describing edges of a binary tree. Each edge is formatted as (P,C) meaning P is the parent of C. Node names are uppercase letters A-Z....

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: