Groupon Code Pair Round
Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2022-07-14Added By Anonymous
Source: Link
Groupon | unknown | Code Pair Round | unknown | unknown
1. Minimum cost of making pile of boxes of same height:
Input is an array, representing height of pile of boxes. Any number of boxes can be removed from the pile with maximum height to make it equal to the height of the second highest pile. At a time boxes can be removed from one pile only. Cost of removing any number of boxes from a pile at a time is unit cost. Return the minimum cost of making the height of all piles of boxes the same.
arr = [5,4,4,5,2]
count = 0
1 iteration each to make piles of height 5 -> 4; count = 2
1 iteration each to make piles of height 4 -> 2; count = 6
answer = 6
Link: https://leetcode.com/discuss/interview-question/364618/
2. Minimum length subarray having degree same as the array
arr = [1,2,1,3,2]
degree of arr = 2
subarray with degree 2 are [1,2,1] and [2,1,3,2] but the smallest out of the two is [1,2,1] having length 3
output = 3
1. Minimum cost of making pile of boxes of same height:
Input is an array, representing height of pile of boxes. Any number of boxes can be removed from the pile with maximum height to make it equal to the height of the second highest pile. At a time boxes can be removed from one pile only. Cost of removing any number of boxes from a pile at a time is unit cost. Return the minimum cost of making the height of all piles of boxes the same.
arr = [5,4,4,5,2]
count = 0
1 iteration each to make piles of height 5 -> 4; count = 2
1 iteration each to make piles of height 4 -> 2; count = 6
answer = 6
Link: https://leetcode.com/discuss/interview-question/364618/
2. Minimum length subarray having degree same as the array
arr = [1,2,1,3,2]
degree of arr = 2
subarray with degree 2 are [1,2,1] and [2,1,3,2] but the smallest out of the two is [1,2,1] having length 3
output = 3