The "Best Position for a Service Centre interview question" is a classic geometric optimization challenge. You are given the coordinates of several customers. You need to find a new coordinate such that the sum of the Euclidean distances from this center to all customers is minimized. This is a well-known mathematical problem called the "Geometric Median" or the "Fermat-Weber point."
Uber and Citadel ask the "Best Position for a Service Centre coding problem" to test a candidate's understanding of Numerical Optimization and Iterative Algorithms. Since there is no simple closed-form formula for the geometric median of more than four points, you must use an iterative approach like "Weiszfeld's algorithm" or a "Randomized/Gradient Descent" search. It evaluates advanced "Math interview pattern" and "Geometry" skills.
This problem is typically solved using Gradient Descent or Ternary Search (for each dimension).
Customers: (0,1), (1,0), (1,2), (2,1)
(1,1). Total distance: .(1.1, 1): Total distance increases.(0.9, 1): Total distance increases.(1,1) is already optimal for this symmetric set.
For non-symmetric sets, the algorithm would "crawl" toward the point that minimizes the total sum.Numerical optimization is rare in interviews but critical for specialized roles in finance or logistics. Practice "Hill Climbing" or simple gradient descent logic. Remember that for convex functions (like this one), any local minimum is also the global minimum.