Skip to content

Commit 3c76811

Browse files
authored
Create 2274-maximum-consecutive-floors-without-special-floors.js
1 parent f479af2 commit 3c76811

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* @param {number} bottom
3+
* @param {number} top
4+
* @param {number[]} special
5+
* @return {number}
6+
*/
7+
var maxConsecutive = function(bottom, top, special) {
8+
special.sort((a, b) => a - b)
9+
let res = 0
10+
11+
if(bottom < special[0]) {
12+
res = special[0] - bottom
13+
}
14+
for(let i = 1; i < special.length; i++) {
15+
res = Math.max(res, special[i] - special[i - 1] - 1)
16+
}
17+
if(top > special[special.length - 1]) {
18+
res = Math.max(res, top - special[special.length - 1])
19+
}
20+
21+
return res
22+
};

0 commit comments

Comments
 (0)