1

You can append all 'r' nodes to the initial empty queue. Instead of checking whether the front node is the single destination node, check whether the front node is in the set of all destination nodes. With the two extensions above, the Lee algorithm will be able to find the shortest distance between the closest pair of 'r' and 'b' nodes in $O(MN)$ time. ...


Only top voted, non community-wiki answers of a minimum length are eligible