i am not able to understand what testcases i am failing.
code link
Religious people failing testcases
@Daniyal-Farooque-446199309332205
Algorithm:
i am making connected components
then cost of building temple is less then simply build a temple in each node
else
eg. if( a component has 5 nodes => 1 of them has a temple made rest 4 will incur cost of road repair)
for no of independ component build 1 temple in each component
in the edgesInConnectedComponent vector i am storing the no of nodes each connected component has
so multiply the cost of road repair with no of nodes in each connected component
refer the code to get a better understanding
I have used the same logic as yours but couldn’t pass the test cases. Please correct my code i had send it in earlier post.
thanks it worked, i was not storing the answer so i thought i dont have to care about overflow so i totally forgot about the range of the costs.