Problem Link : CLEANRBT . I read here that problem can be solved by first finding all distances between each pair of dirty cells using BFS .That part i understood.
Now we need to find answer for each of the case where final position of the robot will be the i'th dirty cell and i we need to take minimum for all of them .I didn't understood how to do that . For example there are two dirty cells say b,c . Then we need to calculate $$$min(distance(o,a)+distance(a,b),distance(o,b)+distance(b,a))$$$ .Here 'o' is the starting position of the robot.How to do that ? What will be the transition formula ?
Thanks