Maximum Consecutive Floors Without Special Floors LeetCode solution in Java
1class Solution {2public int maxConsecutive(int bottom, int top, int[] special) {3int max = Integer.MIN_VALUE;45Arrays.sort(special);67// from bottom to the first special floor8max = Math.max(max, special[0] - bottom);910// middle floors11for (int i = 1; i < special.length; i++) {12max = Math.max(max, special[i] - special[i - 1] - 1);13}1415// from last special floor to the top16max = Math.max(max, top - special[special.length - 1]);1718return max;19}20}