2
count = 0 # Found candy. Class variable to keep found candy9
containedBoxes: List[List[int]],10
initialBoxes: List[int],12
boxes = [] # Newly found boxes14
for box in initialBoxes:15
if status[box]: # The box is open17
boxes.extend(containedBoxes[box]) # Add newly found boxes18
self.count += candies[box] # Count found candy21
1 # Use found keys to open boxes even if we don't have them.24
boxes.append(box) # The box is closed. Keep it for the next iteration.25
if not progress: # Nothing happened. return.27
# Run another iteration with the new 'boxes'28
return self.maxCandies(status, candies, keys, containedBoxes, boxes)