1478. Allocate Mailboxes
Previous1477. Find Two Non-overlapping Sub-arrays Each With Target SumNext1479. Sales by Day of the Week
Last updated
Last updated
https://leetcode.com/problems/allocate-mailboxes
Given the array houses
and an integer k
. where houses[i]
is the location of the ith house along a street, your task is to allocate k
mailboxes in the street.
Return the minimum total distance between each house and its nearest mailbox.
The answer is guaranteed to fit in a 32-bit signed integer.
Example 1:
Example 2:
Example 3:
Example 4:
Constraints:
n == houses.length
1 <= n <= 100
1 <= houses[i] <= 10^4
1 <= k <= n
Array houses
contain unique integers.