Police Station
Easydeshaw
Deshaw interviews coding interview problem: You’re given a 1D number line with distinct police station coordinates (array police_station) and an integer capacity. Choose exactly capacity distinct property locations not at any station. Each property’s cost equals its nearest station distance. Compute and return the minimum total cost. A clear interview question on constraints and distances.
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Input Variables
Execution Result:
