Class Solution
java.lang.Object
g2201_2300.s2274_maximum_consecutive_floors_without_special_floors.Solution
2274 - Maximum Consecutive Floors Without Special Floors.<p>Medium</p>
<p>Alice manages a company and has rented some floors of a building as office space. Alice has decided some of these floors should be <strong>special floors</strong> , used for relaxation only.</p>
<p>You are given two integers <code>bottom</code> and <code>top</code>, which denote that Alice has rented all the floors from <code>bottom</code> to <code>top</code> ( <strong>inclusive</strong> ). You are also given the integer array <code>special</code>, where <code>special[i]</code> denotes a special floor that Alice has designated for relaxation.</p>
<p>Return <em>the <strong>maximum</strong> number of consecutive floors without a special floor</em>.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> bottom = 2, top = 9, special = [4,6]</p>
<p><strong>Output:</strong> 3</p>
<p><strong>Explanation:</strong> The following are the ranges (inclusive) of consecutive floors without a special floor:</p>
<ul>
<li>
<p>(2, 3) with a total amount of 2 floors.</p>
</li>
<li>
<p>(5, 5) with a total amount of 1 floor.</p>
</li>
<li>
<p>(7, 9) with a total amount of 3 floors.</p>
</li>
</ul>
<p>Therefore, we return the maximum number which is 3 floors.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> bottom = 6, top = 8, special = [7,6,8]</p>
<p><strong>Output:</strong> 0</p>
<p><strong>Explanation:</strong> Every floor rented is a special floor, so we return 0.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= special.length <= 10<sup>5</sup></code></li>
<li><code>1 <= bottom <= special[i] <= top <= 10<sup>9</sup></code></li>
<li>All the values of <code>special</code> are <strong>unique</strong>.</li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
maxConsecutive
public int maxConsecutive(int bottom, int top, int[] special)
-