I have been trying to solve this problem, but I don\'t know how should I approach this problem. I think this is a graph problem, then again I am not sure what algorithm shou