Intuit onsite

Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2021-08-19Added By Anonymous
Source: Link

I was asked this question for my Intuit onsite round.

Given an integer k, and an array of size n, transform the array to size k such that the resultant array is evenly distributed.


Input:

k=2

arr=[5,5,5,5]


Output

arr=[10, 10]

—————————————

k=3

Arr = [20, 15,10, 50, 22]


Output

Arr = [32, 35, 50]

Any pointers on how to best solve this?

Comments