Panda Guru LogoPanda
Guru

Amazon OA question SDE1

Round 1

Questions: Given a list of array with positive numbers and capacity c. Give the minimum number of boxes that needed to be unloaded so that below condition is satisfied: max(array) <= capacity * min(array)

For example, array = [1,4,3,2] and capacity = 2. The minimum number of boxes to be unloaded = 1. The numbers in the array could contain duplicates.

Follow-up Question

I could not think of a greedy approach. Could someone help me in finding one? I could only think of a recursive and memoization solution because the condition depends on both min and max values of arrays. So, I am creating two subproblems:

  1. removing the minimum item
  2. removing the maximum item and continuing the recursion until the condition is satisfied.

Is there a better approach?

Candidate's Approach

No approach provided.

Interviewer's Feedback

No feedback provided.