Search
⌘K
Get Premium
Leetcode 1743. Restore the Array From Adjacent Pairs
Given unordered adjacent pairs from an array with unique elements, reconstruct the original array by treating values as nodes in a graph and the pairs as edges, then find an endpoint (degree 1) and traverse the path to recover the sequence. Constraints: n up to 1e5 and pairs are given in arbitrary order.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.