• + 0 comments

    Note for trying to solve this question:

    The range [L,R] indicates the minumum and maximum cost of your entire path. This does not mean to sum the weights throughout your path. For example, for the path {1,3} (which is {3,1} because it is bidirectional) the Cost = Maximum weight = 2 and not 3. To explain further, for the path {1,3} you must go through node 4 because there is no direct path from Node 1 to Node 3. Therefore, the full path for {1,3} is 1->4->3 and vice versa. Since the weight of {1,4} (a direct edge) is 2 and the weight of {4,3} is 1 the weight of 2 is the max. for the range [1,2] the only two path that fall within these cost are {1,4} with a cost of 2, {1,3} with a cost of 2 (explanation above) and {3,4} witha cost of 1.