Company: Salesforce SDE1 offcampus_23june

Difficulty: medium

Problem Statement

Minimum Time Students are working on a science project demonstrating magnetic properties. There are n plates positioned at coordinates (x[i], y[i]). Each plate has a magnetic power d. When a plate is collected, all plates within d units of distance along the same row or column are attracted and collected instantly. This is a chain property: if plate A attracts B, and plate C is attracted to plate A, then all three plates are collected simultaneously. Assuming any single plate can be chosen and collected in one second, calculate the minimum time required to collect all plates. Example n = 4 d = 1 x = [0, 0, 1, 2] y = [0, 1, 0, 2] Plates 1, 2, and 3 are within d = 1 unit of distance from each other, so they are collected in one second. Plate 4 requires another second to collect. Therefore, the minimum time required is 2 seconds. Function Description Complete the function getMinTime in the editor with the following parameter(s): int n: the number of plates int d: the magnetic power of the

More Salesforce SDE1 offcampus_23june OA questionsInterview experiences