Class Solution
-
- All Implemented Interfaces:
public final class Solution2274 - Maximum Consecutive Floors Without Special Floors\.
Medium
Alice manages a company and has rented some floors of a building as office space. Alice has decided some of these floors should be special floors , used for relaxation only.
You are given two integers
bottomandtop, which denote that Alice has rented all the floors frombottomtotop( inclusive ). You are also given the integer arrayspecial, wherespecial[i]denotes a special floor that Alice has designated for relaxation.Return the maximum number of consecutive floors without a special floor.
Example 1:
Input: bottom = 2, top = 9, special = 4,6
Output: 3
Explanation: The following are the ranges (inclusive) of consecutive floors without a special floor:
(2, 3) with a total amount of 2 floors.
(5, 5) with a total amount of 1 floor.
(7, 9) with a total amount of 3 floors.
Therefore, we return the maximum number which is 3 floors.
Example 2:
Input: bottom = 6, top = 8, special = 7,6,8
Output: 0
Explanation: Every floor rented is a special floor, so we return 0.
Constraints:
<code>1 <= special.length <= 10<sup>5</sup></code>
<code>1 <= bottom <= speciali<= top <= 10<sup>9</sup></code>
All the values of
specialare unique.
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
Modifier and Type Method Description final IntegermaxConsecutive(Integer bottom, Integer top, IntArray special)-
-
Method Detail
-
maxConsecutive
final Integer maxConsecutive(Integer bottom, Integer top, IntArray special)
-
-
-
-