← All questions
MediumCoding

Boats to Save People

Asked atIDFC FIRST BankMeta
1Give yourself 5 minutes
2Answer out loud, not in your head
3Then compare with the answer below
0
Stuck? Show a way to structure it+
  1. 01Sort people by weight and place pointers at the lightest and heaviest.
  2. 02The heaviest remaining person must take the next boat.
  3. 03Pair that person with the lightest only if they fit, then count one boat.
  4. 04Send the heaviest alone when even the lightest remaining person cannot fit.

Reference answer

Then expect these follow-ups

  • Why must the heaviest remaining person be handled now?

    Tests: greedy proof

  • What changes if a boat can carry three people?

    Tests: problem complexity

Free to read · better with Enzo

Practice this out loud with Enzo

Enzo runs it as a mock interview, pushes back with follow-ups, and grades you on the rubric.

Next question