find error /** * @param {number[]} status * @param {number[]} candies * @param…
- User
find error
/**
-
@param {number[]} status
-
@param {number[]} candies
-
@param {number[][]} keys
-
@param {number[][]} containedBoxes
-
@param {number[]} initialBoxes
-
@return {number} */ var maxCandies = function (status, candies, keys, containedBoxes, initialBoxes) { const stack = [] const opened = [...status] const visited = Array(status.length).fill(false)
for (box of initialBoxes) { if (opened[box] === 1) { stack.push(box) } }
let res = 0 while (stack.length > 0) { const i = stack.pop() if (visited[i]) { continue } res += candies[i] visited[i] = true
codefor (const box of containedBoxes[i]) { if (opened[box] === 1 && !visited[box]) { stack.push(box) } } for (const key of keys[i]) { if (opened[key] === 0) { opened[key] = 1 if (!visited[key]) { stack.push(key) } } }
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.