An online marketplace has onboarded n merchants, each operating within a designated geographical range. The operating zone of merchant i is defined by the interval spanning from zoneStart[i] to zoneEnd[i].
A set of k merchants is termed cohesive (inclusive) if there exists at least one merchant whose operational territory overlaps with (or touches) all the other (k-1) merchants’ operational zones.
The marketplace plans to relocate some merchants to new areas. Your goal is to determine the minimum number of merchants that need to be moved so that the remaining merchants form a cohesive subset.
Complete the predefined function in the editor.
minimumRetailers has the following parameters:
int zoneStart[n]: the left ends of the operating regionsint zoneEnd[n]: the right ends of the operating regions
Returns
int: the smallest number of merchants that need to be relocated
Constraints
1 ≤ n ≤ 10^51 ≤ zoneStart[i] ≤ zoneEnd[i] ≤ 10^9 (1 <= i < n)- All regions have regions with the same start and end points.
zoneStart = [1, 3, 4, 6, 9] zoneEnd = [2, 8, 5, 7, 10] return = 2

zoneStart = [1, 2, 3, 4] zoneEnd = [2, 3, 5, 5] return = 1
zoneStart = [1, 2, 4] zoneEnd = [7, 5, 6] return = 0
- Count Promotional PeriodsOA · Seen Jun 2026
- Find Maximum Total Amount (SDE I, Fungible :)Seen Jun 2026
- Get Minimum AmountOA · Seen Jun 2026
- Find Minimum CostOA · Seen Jun 2026
- Get Smallest Base SegmentOA · Seen Jun 2026
- Select Least Resource TasksOA · Seen Jun 2026
- Product Category Group SizesPHONE SCREEN · Seen May 2026
- Count Connected ComponentsPHONE SCREEN · Seen May 2026
public int minimumRetailers(int[] zoneStart, int[] zoneEnd) {
// write your code here
}