We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent cf34946 commit 3cb9b97Copy full SHA for 3cb9b97
Recursive/FloodFill.js
@@ -98,10 +98,13 @@ function breadthFirstFill(
98
rgbData[currentLocation[0]][currentLocation[1]] = replacementColor
99
100
for (let i = 0; i < neighbors.length; i++) {
101
- const x = currentLocation[0] + neighbors[i][0]
102
- const y = currentLocation[1] + neighbors[i][1]
103
- if (x >= 0 && x < rgbData.length && y >= 0 && y < rgbData[0].length) {
104
- queue.push([x, y])
+ const newLocation = [
+ currentLocation[0] + neighbors[i][0],
+ currentLocation[1] + neighbors[i][1]
+ ]
105
+ isInside(rgbData, newLocation)
106
+ if (isInside(rgbData, newLocation)) {
107
+ queue.push(newLocation)
108
}
109
110
0 commit comments