Skip to content

Commit b92dfa6

Browse files
authored
Update 1042-flower-planting-with-no-adjacent.js
1 parent dbbe2c2 commit b92dfa6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

1042-flower-planting-with-no-adjacent.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ const gardenNoAdj = function(N, paths) {
1919
let colors = new Array(4).fill(false);
2020
for (let neighbor of map[i]) {
2121
if (result[neighbor] !== -1) {
22-
colors[result[neighbor] - 1] = true;
22+
colors[result[neighbor]] = true;
2323
}
2424
}
2525
for (let j = 0; j < colors.length; j++) {
2626
if (!colors[j]) {
27-
result[i] = j + 1;
27+
result[i] = j;
2828
break;
2929
}
3030
}
3131
}
32-
return result;
32+
return result.map(i => ++i);
3333
};

0 commit comments

Comments
 (0)