Company: Salesforce SDE1 offcampus_23june
Difficulty: medium
Minimum Time Problem Description Students are working on a science project that demonstrates magnetism. There are n plates, and plate i is positioned at the integer coordinates (x[i], y[i]) . Every plate has the same magnetic power d . When a plate is collected, every plate that lies in the same row or the same column within d units of distance is attracted and collected instantly. Precisely, plates i and j attract each other when either of these holds: x[i] == x[j] and |y[i] - y[j]| <= d (same column), or y[i] == y[j] and |x[i] - x[j]| <= d (same row). Attraction is a chain property: if plate A attracts plate B, and plate C is attracted to plate A or to plate B, then all three plates are collected at the same moment, and so on through any longer chain. Choosing and collecting any single plate takes one second; every plate pulled in through the chain comes with it at no extra cost. Find the minimum time, in seconds, needed to collect all n plates. Complete the function getMinTime