Minimum Retailers
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.
1Example 1

2Example 2
3Example 3
Constraints
Limits and guarantees your solution can rely on.