Tap here to switch tabs
Problem
Submissions

Problem: Maximum Consecutive Floors Without Special Floors

med
30 min
Try to solve the Maximum Consecutive Floors Without Special Floors problem.

Statement

An organization has rented a series of consecutive building floors spanning from bottom to top, inclusive. You are given two integers bottom and top, along with an integer array special, where each special[i] represents a designated special floor within this range.

Return the maximum number of consecutive floors in the range [[bottom, top]] that do not contain any special floor.

Constraints:

  • 1≤1 \leq special.length ≤105\leq 10^5

  • 1≤1 \leq bottom ≤\leq special[i] ≤\leq top ≤109\leq 10^9

  • All the values of special are unique.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Consecutive Floors Without Special Floors

med
30 min
Try to solve the Maximum Consecutive Floors Without Special Floors problem.

Statement

An organization has rented a series of consecutive building floors spanning from bottom to top, inclusive. You are given two integers bottom and top, along with an integer array special, where each special[i] represents a designated special floor within this range.

Return the maximum number of consecutive floors in the range [[bottom, top]] that do not contain any special floor.

Constraints:

  • 1≤1 \leq special.length ≤105\leq 10^5

  • 1≤1 \leq bottom ≤\leq special[i] ≤\leq top ≤109\leq 10^9

  • All the values of special are unique.