Skip to content

Commit 45149f2

Browse files
committed
Runtime: 929 ms (Top 36.36%) | Memory: 127.8 MB (Top 45.45%)
1 parent 31f7b02 commit 45149f2

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

scripts/algorithms/M/Map of Highest Peak/Map of Highest Peak.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
// Runtime: 929 ms (Top 36.36%) | Memory: 127.8 MB (Top 45.45%)
12
var highestPeak = function(isWater) {
23
const RN = isWater.length, CN = isWater[0].length;
34
const output = [...Array(RN)].map(() => Array(CN).fill(-1));
45
const dir = [[1, 0], [-1, 0], [0, 1], [0, -1]]
56
let queue = []
6-
7+
78
for(let r = 0; r < RN; r++) {
89
for(let c = 0; c < CN; c++) {
910
if(isWater[r][c]) {
@@ -15,7 +16,7 @@ var highestPeak = function(isWater) {
1516

1617
while(queue.length) {
1718
const next = []
18-
19+
1920
for(let [r, c] of queue) {
2021
for(let [dr, dc] of dir) {
2122
dr += r;
@@ -28,4 +29,4 @@ var highestPeak = function(isWater) {
2829
queue = next;
2930
}
3031
return output;
31-
};
32+
};

0 commit comments

Comments
 (0)