PROBLEM LINK:Setter: Jayprakash Mahto DIFFICULTY:EASY PREREQUISITES:PROBLEM:Given an undirected weighted graph with N nodes and M edges. K nodes are initially reachable. A node is reachable from another reachable node if their edge weight is $\leq$ S. Find out how many nodes are reachable. CONSTRAINTS:
QUICK EXPLANATION:Run a DFS from each reachable node. If any neighbour has edge weight $\leq$ S, it is reachable and run a DFS from it. Maintain a visited array so that you visit each node atmost once. Print the number of nodes that were visited. EXPLANATION:
COMPLEXITY:
AC SOLUTIONS:SIMILAR PROBLEMS:Feel free to share your approach if it differs. If you have any doubts, or if you feel stuck at any point, you can ask them below. We would love to hear your suggestions :) Thanks to @taran_1407 and @vijju123 for their constant guidance and support.
This question is marked "community wiki".
asked 26 Jan, 19:06
