You are given
status: An integer array of length status[i] is
candies: An integer array of length candies[i] represents the number of candies inside the
keys: A keys[i] contains the labels of boxes for which keys can be found inside the
containedBoxes: A containedBoxes[i] contains the labels of other boxes located inside the
initialBoxes: An integer array containing the labels of the boxes you start with.
You can open a box if you possess it and it is either already open or you have obtained its corresponding key. When you open a box, you collect all the candies inside it, obtain all the keys contained within it, and discover all the new boxes inside it.
Return the maximum number of candies you can collect by opening the available boxes according to these rules.
Constraints:
n == status.length == candies.length == keys.length == containedBoxes.length
status[i] is either
candies[i]
keys[i].length
keys[i][j]
All values of keys[i] are unique.
containedBoxes[i].length
containedBoxes[i][j]
All values of containedBoxes[i] are unique.
Each box is contained in at most one box.
initialBoxes.length
initialBoxes[i]
You are given
status: An integer array of length status[i] is
candies: An integer array of length candies[i] represents the number of candies inside the
keys: A keys[i] contains the labels of boxes for which keys can be found inside the
containedBoxes: A containedBoxes[i] contains the labels of other boxes located inside the
initialBoxes: An integer array containing the labels of the boxes you start with.
You can open a box if you possess it and it is either already open or you have obtained its corresponding key. When you open a box, you collect all the candies inside it, obtain all the keys contained within it, and discover all the new boxes inside it.
Return the maximum number of candies you can collect by opening the available boxes according to these rules.
Constraints:
n == status.length == candies.length == keys.length == containedBoxes.length
status[i] is either
candies[i]
keys[i].length
keys[i][j]
All values of keys[i] are unique.
containedBoxes[i].length
containedBoxes[i][j]
All values of containedBoxes[i] are unique.
Each box is contained in at most one box.
initialBoxes.length
initialBoxes[i]