Given an R x C grid of letters "P", "F", and ".", you have one person "P" and his friends "F".
The person will go visit all his friends and can walk over the empty spaces to visit his friends.
He visits a friend when he walks onto the friend's square.
He can walk over his friends.
Find the length of the shortest path for him to visit all his friends.
"..P..",
"F...F",
"FF.FF"
The answer is 9. Can someone please help solving this question?