How to solve this problem? Amazon SDE-1 round
Anonymous User
1187

Hi,
I came across this question of a Amazon SDE-1 round, how can this problem be solved?

Let us consider a parcel service X which stores its parcel in a warehouse.
The company has found that it takes a lot of time to load the parcels onto the truck if there are gaps between
the parcels and hence wants to group them together. Help company X to find the minimum number of moves to group the parcels together.
Here ‘P’ denotes a parcel and ‘_’ denotes an empty slot.

Eg:

  1. [P, _ , P, _ , P] , Ans = 1
  2. [P, _, P, _, _, P, P] , Ans = 2
  3. [P, _, _, _, _] , Ans = 0
Comments (8)