Question bank › Dynamic Programming
Dsa Dynamic Programming Medium

Minimize Distance in Array

You are given an array of integers representing the positions of houses on a street. Your goal is to minimize the maximum distance between any two adjacent houses by determining optimal new positions to add houses. Write a function that takes an array and the number of houses to add, returning the minimized maximum distance. Input format: - The first line contains two integers n and k, where n is the number of current houses and k is the number of new houses to add. - The second line contains n space-separated integers representing the positions of the houses. Output format: - A single integer representing the minimized maximum distance between adjacent houses. Example: Input: 5 2 1 2 8 10 12 Output: 2

Key concepts

dynamic_programmingarray

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.