Sprinklr OA
Anonymous User
2593
May 25, 2021
May 25, 2021

You are given an undirected graph that contains N+1 nodes and M edges. These nodes are numbered from 0 to N. Initially, you start at node 0. Each node (except node 0) has a priority associated with it that is denoted by the array denoted as P. You have to follow these commands to visit each node in the path:

You have to start at node O and move to the next unvisited node which is directly connected to node 0 and havng the highest priority.
If the priority is the same for multiple nodes, then you have to select the nodes that have the minimum distance between them.
After going to the next node, you have to again select a connected node that has the highest priority among the remaining unvisited nodes.
If there are no adjacent unvisited node at a point, then you have to traverse back to the previous node from where you came to the present node for the first time.
You cannot traverse the path once you reach the last unvisited node.
If the distance between the node X to node Y is d, then the time elapsed to reach from one node to another is d units. Your task is to find the time arrive at each node (except node 0) for the first time.

Comments (3)