I had my elimination round with Google in January 2022, and I got rejected. The below question was asked to me, I wanted to know the solution to it.
We have series of animal cages like cage1, cage2, cage3 and so on. Each cage is fitted with security system, so that whenever an animal leaves it's cage,
the system starts triggering an alarm.
Whenever an alarm is triggered, the neighbouring cages animal start shouting, and this goes on for all continous neighbours(who are occupied).
Given a list of cages which need to be vacated, find the optimum order of vacating the cages. The optimality of the order is determined by the number of treats given.
Input : 7, [2, 7]
Output = [2, 7]