Please solve the programming task below using a self-contained code snippet in a markdown code block.

Given the array houses where houses[i] is the location of the ith house along a street and an integer k, allocate k mailboxes in the street.
Return the minimum total distance between each house and its nearest mailbox.
The test cases are generated so that the answer fits in a 32-bit integer.
 
Please complete the following python code precisely:
```python
class Solution:
    def minDistance(self, houses: List[int], k: int) -> int:
```