Problem Link: https://www.codechef.com/LRNDSA08/problems/MARLA

Solution Link: https://pastebin.com/JL6wBs8T

In this problem, from what I have understood, we just have to find the largest connected component (components consist of the same numbers) and among the largest connected components choose the one with the least strength. My implementation is passing most of the test cases and failing only 3. Could someone please help me?