Game of Dominoes Problem Statement
Rafiq loves to play with piles of dominoes, especially when they are of equal heights. His father gifted him 'N' piles of dominoes, each with a positive number of stacked dominoes. His father wants to know the minimum cost of making all dominoes in each consecutive window of length 'K' equal in height. The cost for either adding or removing one domino from any pile is one unit.
Example:
Input:
T = 1
N = 5, K = 3
heights = [1, 3, 2, 4, 5]
Output:
Output Example: 1 2 3
Explanation:
The output consists of minimum costs calculated for each window of size 'K'. Each value represents the minimal cost to make the piles in that window equal in height.
Constraints:
1 <= T <= 10
1 <= N <= 10000
1 <= K <= N
1 <= height[i] <= 105
Calculate minimum cost to make consecutive windows of domino piles equal in height.
Iterate through each window of size K and calculate the minimum cost to make piles equal in height.
Keep track of the ...read more
Top Procol Software Developer Intern interview questions & answers
Popular interview questions of Software Developer Intern
Reviews
Interviews
Salaries
Users/Month