The main purpose of this problem is to identify the phone calls among two people. First, we have to consider the roll number as nodes, and the friendship among any two members as edges. If we start a Breadth First Search from node 0, at the end we will find a BFS tree. While exploring the neighbour nodes, we have to explore them in ascending order, to get an unique BFS tree. Then we will just store the edge of the BFS tree and for any query, if there is an edge between a and b in the BFS tree, we will print “Yes” and “No” otherwise.

Statistics

89% Solution Ratio
mohanr7073Earliest, Sep '20
monon_mirzaFastest, 0.1s
asifm91Lightest, 6.2 MB
asifm91Shortest, 467B
Toph uses cookies. By continuing you agree to our Cookie Policy.