</>OfferRetriever
DashboardDiscuss
NEW

Summer Sale

Limited Time Deal: Unlock all premium questions for over 30% off

$10.42$7.08

14

:

03

:

45

:

34

Get this deal
Back to Dashboard

Distribution Center Placement

Medium

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.

PRODUCT
PricingDashboardDiscussOfferRetriever vs LeetCode
LEGAL
POPULAR COMPANIES
GoogleMetaAmazonMicrosoftNetflixStripeUberTikTokBrowse all companies →

© 2026 Purple Business Holdings LLC. All rights reserved. See Terms of Service.