Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit c8272ac

Browse files
authored
Create Maximum Consecutive Floors Without Special Floors.java
1 parent 3fdac5f commit c8272ac

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution {
2+
public int maxConsecutive(int bottom, int top, int[] special) {
3+
Arrays.sort(special);
4+
int maxConsecutiveFloors = Math.max(special[0] - bottom, top - special[special.length - 1]);
5+
for (int specialFloor : special) {
6+
int emptyFloors = specialFloor - bottom;
7+
bottom = specialFloor + 1;
8+
maxConsecutiveFloors = Math.max(maxConsecutiveFloors, emptyFloors);
9+
}
10+
return maxConsecutiveFloors;
11+
}
12+
}

0 commit comments

Comments
 (0)