Summer Sale
Limited Time Deal: Unlock all premium questions for over 30% off
14
:
03
:
45
:
34
Distribution Center Placement
A logistics company is expanding its distribution network along a single highway. You are given an array of integers locations representing the coordinates of candidate hub sites. Find the optimal hub coordinate to place a distribution center that minimizes total shipping distance to all sites.
Return a two-element list [hub, totalDistance] where hub is chosen from locations to minimize totalDistance = sum of |hub - locations[i]| over all i. If multiple hub coordinates give the same minimum total distance, choose the smaller one.
...
OfferRetriever
Master technical interviews with real questions from top companies. Build your confidence and career.
LEGAL
© 2026 Purple Business Holdings LLC. All rights reserved. See Terms of Service.