10592 - Freedom Fighter

Difficulty : medium

Solution Description :

Flood Fill problem

From left to right and top to bottom if grid[i][j] is not equal '.' then run flood fill for star (*).
In start flood fill if you find the character 'B' then run 2nd flood fill for freedom fighter or if you find 'P' then run 3rd flood fill for enemy. 

I calculated the number of groups of freedom fighters that are connected to the enemies. Then simply I multiply that amout by 2 to get the total fighting group.