← Questions

Maximum candies from boxes with keys

0
AirbnbCodingLast asked May 2026

Some boxes are open and some are locked. Each box holds candies, keys to other boxes, and more boxes. You start with a few boxes. You may open a box once you have it and it is open or you hold its key. Return the most candies you can collect. Process boxes with a queue, and remember boxes you hold but cannot open yet, since a key may turn up later.

Write and test your solution herePython in your browser, the question's tests level by level, saved for you.Sign in to start coding