Answer: HARLEY DAVIDSON TECH Hiring Challenge | Off-Campus OA (2023)

Answer · Posted Jun 2026

Approach Use the Disjoint Set Union (Union-Find) data structure. Initially, every node belongs to its own set. For every edge, merge the two connected nodes. After processing all edges, if source and destination belong to the same parent, then a valid path exists. Path Compression is used to optimize the find() operation. Strategy Initialize every node as its own parent. Traverse every edge and perform union operation. Find the parent of source and destination. If both parents are equal, return ...

The full answer & interview discussion are available to premium members.

Log in Create a free account