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
Be the first one to answer
Add answer anonymously...
Top Ola Cabs Software Developer Intern interview questions & answers
Popular interview questions of Software Developer Intern
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app