Place K ATM between N cites

Revision en1, by abba5, 2019-08-08 19:58:56

there is $$$N$$$ number of cites in one dimension. the location of the city is $$$a_{i}$$$ you have to place $$$k$$$ ATM such that the sum of all the cities to its nearest ATM distance is minimum.

I don't remember constraints but it was not big.

the question was asked in Honeywell Hiring Challange(closed).

Brute Force solution

$$$N = 3$$$

$$$A = [1, 2, 3]$$$

$$$K = 1$$$

$$$ans = 2$$$

Thanks in Advance!

Tags #dynamic programing

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English abba5 2019-08-08 19:58:56 530 Initial revision (published)