mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-11 02:58:13 +08:00
44 lines
2.2 KiB
HTML
44 lines
2.2 KiB
HTML
<p><img alt="" src="https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2020/03/21/cinema_seats_1.png" style="height: 149px; width: 400px;"></p>
|
||
|
||
<p>如上图所示,电影院的观影厅中有 <code>n</code> 行座位,行编号从 1 到 <code>n</code> ,且每一行内总共有 10 个座位,列编号从 1 到 10 。</p>
|
||
|
||
<p>给你数组 <code>reservedSeats</code> ,包含所有已经被预约了的座位。比如说,<code>researvedSeats[i]=[3,8]</code> ,它表示第 <strong>3</strong> 行第 <strong>8</strong> 个座位被预约了。</p>
|
||
|
||
<p>请你返回 <strong>最多能安排多少个 4 人家庭</strong> 。4 人家庭要占据 <strong>同一行内连续 </strong>的 4 个座位。隔着过道的座位(比方说 [3,3] 和 [3,4])不是连续的座位,但是如果你可以将 4 人家庭拆成过道两边各坐 2 人,这样子是允许的。</p>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>示例 1:</strong></p>
|
||
|
||
<p><img alt="" src="https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2020/03/21/cinema_seats_3.png" style="height: 96px; width: 400px;"></p>
|
||
|
||
<pre><strong>输入:</strong>n = 3, reservedSeats = [[1,2],[1,3],[1,8],[2,6],[3,1],[3,10]]
|
||
<strong>输出:</strong>4
|
||
<strong>解释:</strong>上图所示是最优的安排方案,总共可以安排 4 个家庭。蓝色的叉表示被预约的座位,橙色的连续座位表示一个 4 人家庭。
|
||
</pre>
|
||
|
||
<p><strong>示例 2:</strong></p>
|
||
|
||
<pre><strong>输入:</strong>n = 2, reservedSeats = [[2,1],[1,8],[2,6]]
|
||
<strong>输出:</strong>2
|
||
</pre>
|
||
|
||
<p><strong>示例 3:</strong></p>
|
||
|
||
<pre><strong>输入:</strong>n = 4, reservedSeats = [[4,3],[1,4],[4,6],[1,7]]
|
||
<strong>输出:</strong>4
|
||
</pre>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>提示:</strong></p>
|
||
|
||
<ul>
|
||
<li><code>1 <= n <= 10^9</code></li>
|
||
<li><code>1 <= reservedSeats.length <= min(10*n, 10^4)</code></li>
|
||
<li><code>reservedSeats[i].length == 2</code></li>
|
||
<li><code>1 <= reservedSeats[i][0] <= n</code></li>
|
||
<li><code>1 <= reservedSeats[i][1] <= 10</code></li>
|
||
<li>所有 <code>reservedSeats[i]</code> 都是互不相同的。</li>
|
||
</ul>
|