Company: Goldman Sachs_22july
Difficulty: medium
Minimum Distance to Warehouses Problem Description You are managing a network of departmental stores on a very long street. You are given an array storeLocations where storeLocations[i] represents the location of the i th branch along the street. To improve the logistics and reduce travel time, you want to establish k warehouses. The objective is to place the k warehouses on the street such that sum of distance of each store to its nearest warehouse is minimum. Note1: The warehouses can only be placed on integer locations on the street Note2: The warehouse can be placed within the store as well i.e. on the same integer location as the store Input Format for Custom Testing The first line contains an integer n, number of storeLocations (length of storeLocations) Each of the next n lines contains an integer storeLocations[i]. The last line would have k. Constraints 1 1 All the integers of storeLocations are unique. Examples Example 1: Input: 5 1 3 8 11 23 3 Output: 5 Explanation: storeLoc