Your Dashboard
Interview Coaching
Learn
System Design
ML System Design
Code
Behavioral
Salary Negotiation
Interview Guides
Leetcode 1478. Allocate Mailboxes
Place k mailboxes on a line to minimize the sum of distances from each house to its nearest mailbox; optimal placement partitions the sorted houses into k contiguous groups served by a mailbox at each group's median, solvable by dynamic programming with precomputed interval costs.
Asked at:
Amazon
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Late September, 2024
Amazon
Senior
Calculate the number of suitable warehouse locations on a number line given delivery center positions and maximum travel distance
Mid September, 2024
Amazon
Mid-level
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. LC: https://leetcode.com/problems/allocate-mailboxes/
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.