White RoomNEW
Back to feed
?
Algo Verified

Tree Isomorphism

Anonymous · Difficulty 3/10
PostedJul 8, 2026
Given adjacency lists of 2 rooted trees of N nodes, determine if the trees are isomorphic. Two trees are isomorphic if one tree can be transformed into the other by reordering of children of nodes. Constraints: N <= 2*10^5 Examples: Input: 5 1 2 1 3 2 4 2 5 1 2 1 3 3 5 3 4 Output: YES Input: 5 1 2 1 3 2 4 2 5 1 2 1 3 3 5 2 4 Output: NO