Answer: Citrix OA Question 2024 July | Graphs | on-campus
Answer · Posted Jun 2026
Solution: Clone Graph — BFS with HashMap Approach We use BFS with a HashMap that maps each original node to its cloned copy. The HashMap serves two purposes: it acts as a visited set (preventing infinite loops in cyclic graphs) and stores the clones for neighbor linking. Create a clone of the starting node and add it to the map. BFS: for each node dequeued, iterate through its neighbors. If a neighbor has not been cloned yet, create its clone ...
The full answer & interview discussion are available to premium members.
Log in Create a free account