Skip to content

feat: update lc problems #3175

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion solution/0400-0499/0489.Robot Room Cleaner/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ tags:

<p>机器人从一个未知的空单元格开始出发,并且你无法访问网格,但你可以使用给定的 API <code>Robot</code> 控制机器人。</p>

<p>你的任务是使用机器人清扫整个房间(即清理房间中的每个空单元格)。机器人具有四个给定的API,可以前进、向左转或向右转。每次转弯 90 度。</p>
<p>你的任务是使用机器人清扫整个房间(即清理房间中的每个空单元格)。机器人具有四个给定的API,可以前进、向左转或向右转。每次转弯 <code>90</code> 度。</p>

<p>当机器人试图移动到一个存在障碍物的单元格时,它的碰撞传感器会检测到障碍物,并停留在当前单元格。</p>

Expand Down
49 changes: 20 additions & 29 deletions solution/1000-1099/1095.Find in Mountain Array/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,39 +22,28 @@ tags:

<p>(这是一个 <strong>交互式问题&nbsp;</strong>)</p>

<p>给你一个 <strong>山脉数组</strong>&nbsp;<code>mountainArr</code>,请你返回能够使得&nbsp;<code>mountainArr.get(index)</code>&nbsp;<strong>等于</strong>&nbsp;<code>target</code>&nbsp;<strong>最小</strong>&nbsp;的下标 <code>index</code>&nbsp;值。</p>

<p>如果不存在这样的下标 <code>index</code>,就请返回&nbsp;<code>-1</code>。</p>

<p>&nbsp;</p>

<p>何为山脉数组?如果数组&nbsp;<code>A</code> 是一个山脉数组的话,那它满足如下条件:</p>

<p><strong>首先</strong>,<code>A.length &gt;= 3</code></p>

<p><strong>其次</strong>,在&nbsp;<code>0 &lt; i&nbsp;&lt; A.length - 1</code>&nbsp;条件下,存在 <code>i</code> 使得:</p>
<p>你可以将一个数组&nbsp;<code>arr</code>&nbsp;称为&nbsp;<strong>山脉数组&nbsp;</strong>当且仅当:</p>

<ul>
<li><code>A[0] &lt; A[1] &lt; ... A[i-1] &lt; A[i]</code></li>
<li><code>A[i] &gt; A[i+1] &gt; ... &gt; A[A.length - 1]</code></li>
<li><code>arr.length &gt;= 3</code></li>
<li>存在一些&nbsp;<code>0 &lt; i &lt; arr.length - 1</code>&nbsp;的&nbsp;<code>i</code>&nbsp;使得:
<ul>
<li><code>arr[0] &lt; arr[1] &lt; ... &lt; arr[i - 1] &lt; arr[i]</code></li>
<li><code>arr[i] &gt; arr[i + 1] &gt; ... &gt; arr[arr.length - 1]</code></li>
</ul>
</li>
</ul>

<p>&nbsp;</p>
<p>给定一个山脉数组&nbsp;<code>mountainArr</code>&nbsp;,返回&nbsp;<strong>最小</strong> 的&nbsp;<code>index</code>&nbsp;使得&nbsp;<code>mountainArr.get(index) == target</code>。如果不存在这样的&nbsp;<code>index</code>,返回&nbsp;<code>-1</code>&nbsp;。</p>

<p>你将&nbsp;<strong>不能直接访问该山脉数组</strong>,必须通过&nbsp;<code>MountainArray</code>&nbsp;接口来获取数据:</p>
<p><strong>你无法直接访问山脉数组</strong>。你只能使用&nbsp;<code>MountainArray</code>&nbsp;接口来访问数组:</p>

<ul>
<li><code>MountainArray.get(k)</code>&nbsp;- 会返回数组中索引为<code>k</code>&nbsp;的元素(下标从 0 开始)</li>
<li><code>MountainArray.length()</code>&nbsp;- 会返回该数组的长度</li>
<li><code>MountainArray.get(k)</code>&nbsp;返回数组中下标为&nbsp;<code>k</code>&nbsp;的元素( 0 开始)</li>
<li><code>MountainArray.length()</code>&nbsp;返回数组的长度。</li>
</ul>

<p>&nbsp;</p>

<p><strong>注意:</strong></p>

<p>对&nbsp;<code>MountainArray.get</code>&nbsp;发起超过 <code>100</code> 次调用的提交将被视为错误答案。此外,任何试图规避判题系统的解决方案都将会导致比赛资格被取消。</p>

<p>为了帮助大家更好地理解交互式问题,我们准备了一个样例 &ldquo;<strong>答案</strong>&rdquo;:<a href="https://leetcode.cn/playground/RKhe3ave" target="_blank">https://leetcode.cn/playground/RKhe3ave</a>,请注意这 <strong>不是一个正确答案</strong>。</p>
<p>调用&nbsp;<code>MountainArray.get</code>&nbsp;超过&nbsp;<code>100</code>&nbsp;次的提交会被判定为错误答案。此外,任何试图绕过在线评测的解决方案都将导致取消资格。</p>

<ol>
</ol>
Expand All @@ -63,13 +52,15 @@ tags:

<p><strong>示例 1:</strong></p>

<pre><strong>输入:</strong>array = [1,2,3,4,5,3,1], target = 3
<pre>
<strong>输入:</strong>array = [1,2,3,4,5,3,1], target = 3
<strong>输出:</strong>2
<strong>解释:</strong>3 在数组中出现了两次,下标分别为 2 和 5,我们返回最小的下标 2。</pre>

<p><strong>示例 2:</strong></p>

<pre><strong>输入:</strong>array = [0,1,2,4,2,1], target = 3
<pre>
<strong>输入:</strong>array = [0,1,2,4,2,1], target = 3
<strong>输出:</strong>-1
<strong>解释:</strong>3 在数组中没有出现,返回 -1。
</pre>
Expand All @@ -79,9 +70,9 @@ tags:
<p><strong>提示:</strong></p>

<ul>
<li><code>3 &lt;= mountain_arr.length() &lt;= 10000</code></li>
<li><code>0 &lt;= target &lt;= 10^9</code></li>
<li><code>0 &lt;= mountain_arr.get(index) &lt;=&nbsp;10^9</code></li>
<li><code>3 &lt;= mountain_arr.length() &lt;= 10<sup>4</sup></code></li>
<li><code>0 &lt;= target &lt;= 10<sup>9</sup></code></li>
<li><code>0 &lt;= mountain_arr.get(index) &lt;=&nbsp;10<sup>9</sup></code></li>
</ul>

<!-- description:end -->
Expand Down
8 changes: 6 additions & 2 deletions solution/1200-1299/1236.Web Crawler/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ tags:

<!-- description:start -->

<p>给定一个链接&nbsp;<code>startUrl</code> 和一个接口&nbsp;<code>HtmlParser</code>&nbsp;,请你实现一个网络爬虫,以实现爬取同&nbsp;<code>startUrl</code>&nbsp;拥有相同&nbsp;<strong>域名标签&nbsp;</strong>的全部链接。该爬虫得到的全部链接可以&nbsp;<strong>任何顺序&nbsp;</strong>返回结果。</p>
<p>给定一个链接&nbsp;<code>startUrl</code> 和一个接口&nbsp;<code>HtmlParser</code>&nbsp;,请你实现一个网络爬虫,以实现爬取同&nbsp;<code>startUrl</code>&nbsp;拥有相同&nbsp;<strong>域名标签&nbsp;</strong>的全部链接。</p>

<p>该爬虫得到的全部链接可以&nbsp;<strong>任何顺序&nbsp;</strong>返回结果。</p>

<p>你的网络爬虫应当按照如下模式工作:</p>

Expand All @@ -32,7 +34,7 @@ tags:

<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/1200-1299/1236.Web%20Crawler/images/urlhostname.png" style="height: 164px; width: 600px;" /></p>

<p>如上所示的一个链接,其域名为&nbsp;<code>example.org</code>。简单起见,你可以假设所有的链接都采用&nbsp;<strong>http协议&nbsp;</strong>并没有指定&nbsp;<strong>端口</strong>。例如,链接&nbsp;<code>http://leetcode.com/problems</code>&nbsp;和&nbsp;<code>http://leetcode.com/contest</code>&nbsp;是同一个域名下的,而链接<code>http://example.org/test</code>&nbsp;和&nbsp;<code>http://example.com/abc</code> 是不在同一域名下的。</p>
<p>如上所示的一个链接,其域名为&nbsp;<code>example.org</code>。简单起见,你可以假设所有的链接都采用&nbsp;<strong>http协议&nbsp;</strong>并没有指定&nbsp;<strong>端口</strong>。例如,链接&nbsp;<code>http://leetcode.com/problems</code>&nbsp;和&nbsp;<code>http://leetcode.com/contest</code>&nbsp;是同一个域名下的,而链接&nbsp;<code>http://example.org/test</code>&nbsp;和&nbsp;<code>http://example.com/abc</code> 是不在同一域名下的。</p>

<p><code>HtmlParser</code> 接口定义如下:&nbsp;</p>

Expand All @@ -44,6 +46,8 @@ interface HtmlParser {

<p>下面是两个实例,用以解释该问题的设计功能,对于自定义测试,你可以使用三个变量&nbsp;&nbsp;<code>urls</code>,&nbsp;<code>edges</code>&nbsp;和&nbsp;<code>startUrl</code>。注意在代码实现中,你只可以访问&nbsp;<code>startUrl</code>&nbsp;,而&nbsp;<code>urls</code>&nbsp;和&nbsp;<code>edges</code>&nbsp;不可以在你的代码中被直接访问。</p>

<p>注意:将尾随斜线“/”的相同 URL 视为不同的 URL。例如,“http://news.yahoo.com” 和 “http://news.yahoo.com/” 是不同的域名。</p>

<p>&nbsp;</p>

<p><strong>示例 1:</strong></p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@ tags:

<!-- description:start -->

<p><em>(这是一个<strong>交互题</strong>)</em></p>
<p><strong>行排序二进制矩阵</strong>&nbsp;表示所有元素都是 <code>0</code> 或 <code>1</code>,并且矩阵的每一行都以非递减排序。</p>

<p>我们称只包含元素&nbsp;<code>0</code>&nbsp;或&nbsp;<code>1</code>&nbsp;的矩阵为二进制矩阵。矩阵中每个<strong>单独</strong>的行都按非递减顺序排序。</p>

<p>给定一个这样的二进制矩阵,返回至少包含一个&nbsp;<code>1</code>&nbsp;的最左端列的索引(从 0 开始)。如果这样的列不存在,返回&nbsp;<code>-1</code>。</p>
<p>给定一个 <strong>行排序二进制矩阵&nbsp;</strong><code>binaryMatrix</code>,返回至少包含一个&nbsp;<code>1</code>&nbsp;的 <strong>最左端列&nbsp;</strong>的索引(从 0 开始)。如果这样的列不存在,返回&nbsp;<code>-1</code>。</p>

<p><strong>您不能直接访问该二进制矩阵。</strong>你只可以通过&nbsp;<code>BinaryMatrix</code>&nbsp;接口来访问。</p>

Expand Down Expand Up @@ -62,15 +60,7 @@ tags:

<pre>
<strong>输入:</strong> mat = [[0,0],[0,0]]
<strong>输出:</strong> -1</pre>

<p><strong>示例 4:</strong></p>

<p><strong><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/1400-1499/1428.Leftmost%20Column%20with%20at%20Least%20a%20One/images/untitled-diagram-6.jpg" style="height:121px; width:161px" /></strong></p>

<pre>
<strong>输入:</strong> mat = [[0,0,0,1],[0,0,1,1],[0,1,1,1]]
<strong>输出:</strong> 1
<strong>输出:</strong> -1
</pre>

<p>&nbsp;</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ reader.compareSub(4, 4, 5, 5) // 返回 1。因此,可以确定 arr[4] 是数
<p><strong>提示:</strong></p>

<ul>
<li><code>2 &lt;= arr.length&nbsp;&lt;= 5 * 10^5</code></li>
<li><code>2 &lt;= arr.length&nbsp;&lt;= 5 * 10<sup>5</sup></code></li>
<li><code>1 &lt;= arr[i] &lt;= 100</code></li>
<li><code>arr</code>&nbsp;中除一个最大元素外,其余所有元素都相等。</li>
</ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ reader.query(4,5,6,7) // 返回 4,因为 nums[4], nums[5], nums[6], nums[7]
<p><strong>提示:</strong></p>

<ul>
<li><code>5 &lt;= nums.length&nbsp;&lt;= 10^5</code></li>
<li><code>5 &lt;= nums.length&nbsp;&lt;= 10<sup>5</sup></code></li>
<li><code>0 &lt;= nums[i] &lt;= 1</code></li>
</ul>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ tags:
<li>在 <strong>连续的</strong> 两周中,你 <strong>不能</strong> 参与并完成同一个项目中的两个阶段任务。</li>
</ul>

<p>一旦所有项目中的全部阶段任务都完成,那么你将停止工作;如果选择任意剩余任务都会导致违反上述规则,那么你也会&nbsp;<strong>停止工作</strong>。注意,由于这些条件的限制,你可能无法完成所有阶段任务。</p>
<p>一旦所有项目中的全部阶段任务都完成,或者执行仅剩的一个阶段任务将会导致你违反上面的规则,你将 <strong>停止工作</strong>。注意,由于这些条件的限制,你可能无法完成所有阶段任务。</p>

<p>返回在不违反上面规则的情况下你&nbsp;<strong>最多</strong>&nbsp;能工作多少周。</p>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/2700-2799/2753.Co

<!-- description:start -->

<p>给定一个代表&nbsp;<strong>环形&nbsp;</strong>街道的类&nbsp;<code>Street</code>&nbsp;和一个正整数&nbsp;<code>k</code>,表示街道上房屋的最大数量(也就是说房屋数量不超过&nbsp;<code>k</code>)。每个房屋的门初始时可以是开着的也可以是关着的(至少有一个房屋的门是开着的)。</p>
<p>给定一个代表&nbsp;<strong>环形&nbsp;</strong>街道的类&nbsp;<code>Street</code>&nbsp;的对象&nbsp;<code>street</code> 和一个正整数&nbsp;<code>k</code>,表示街道上房屋的最大数量(也就是说房屋数量不超过&nbsp;<code>k</code>)。每个房屋的门初始时可以是开着的也可以是关着的(至少有一个房屋的门是开着的)。</p>

<p>刚开始,你站在一座房子的门前。你的任务是计算街道上的房屋数量。</p>

Expand Down