Please help me debug my solution for this problem NEW YEAR DOMINO My submission :14311431 My Idea : --Treat each domino as an interval.
--Then find connected components based on intersection.
--Store range of each connected component i.e. minL,maxR.
--for each query a,b
--define cost(cc[a],cc[b]) as cost of going from one connected component to another.
--cost(cc[a],cc[b]) = minL[cc[b]]-maxR[cc[a]] (given b>a).
--However min cost = sum of costs (starting from cc[a]) to next one till cc[b] reached.