Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
If k =1, the minimum distance is obtained allocating the mailbox in the median of the array houses.
Generalize this idea, using dynamic programming allocating k mailboxes.