Skip to content

Commit dbbe2c2

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

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

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

+6-9
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,17 @@
44
* @return {number[]}
55
*/
66
const gardenNoAdj = function(N, paths) {
7-
let map = {};
7+
const map = {};
88
for (let i = 0; i < N; i++) {
99
map[i] = [];
1010
}
11-
1211
for (let path of paths) {
13-
let lhs = path[0] - 1;
14-
let rhs = path[1] - 1;
15-
map[lhs].push(rhs);
16-
map[rhs].push(lhs);
12+
let l = path[0] - 1;
13+
let r = path[1] - 1;
14+
map[l].push(r);
15+
map[r].push(l);
1716
}
18-
19-
let result = new Array(N).fill(-1);
17+
const result = new Array(N).fill(-1);
2018
for (let i = 0; i < N; i++) {
2119
let colors = new Array(4).fill(false);
2220
for (let neighbor of map[i]) {
@@ -31,6 +29,5 @@ const gardenNoAdj = function(N, paths) {
3129
}
3230
}
3331
}
34-
3532
return result;
3633
};

0 commit comments

Comments
 (0)