Problem Link
PROBLEM NAME :- War and Business AUTHOR :- @twinklesharma
CONTEST :- CLADDING THE CODE
ORGANIZER :- ROBOTICS CLUB MMMUT
Solution
In question a 2D grid is given and we have to find number of strongly connected character ‘P’ and total ‘P’.
This can be done by Graph Theory or Pattern analysis but according to graph theory is more general, In this question we’ll assume a ‘P’ or ‘G’ as a node of graph and the all four neighbour character as connected component with edges. This can be achieved with DFS on Graph
Code
Link to Working Code