Skip to content

feat: update lc problems #4410

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 2 commits into from
May 18, 2025
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
15 changes: 15 additions & 0 deletions solution/0100-0199/0195.Tenth Line/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,41 @@ tags:
<p>Assume that <code>file.txt</code> has the following content:</p>

<pre>

Line 1

Line 2

Line 3

Line 4

Line 5

Line 6

Line 7

Line 8

Line 9

Line 10

</pre>

<p>Your script should output the tenth line, which is:</p>

<pre>

Line 10

</pre>

<div class="spoilers"><b>Note:</b><br />

1. If the file contains less than 10 lines, what should you output?<br />

2. There&#39;s at least three different solutions. Try to explore all possibilities.</div>

<!-- description:end -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ tags:

<ul>
<li><code>1 &lt;= n &lt;= 100</code></li>
<li><code>1 &lt;= logs.length &lt;= 500</code></li>
<li><code>2 &lt;= logs.length &lt;= 500</code></li>
<li><code>0 &lt;= function_id &lt; n</code></li>
<li><code>0 &lt;= timestamp &lt;= 10<sup>9</sup></code></li>
<li>两个开始事件不会在同一时间戳发生</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ So function 0 spends 2 + 4 + 1 = 7 units of total time executing, and function 1

<ul>
<li><code>1 &lt;= n &lt;= 100</code></li>
<li><code>1 &lt;= logs.length &lt;= 500</code></li>
<li><code>2 &lt;= logs.length &lt;= 500</code></li>
<li><code>0 &lt;= function_id &lt; n</code></li>
<li><code>0 &lt;= timestamp &lt;= 10<sup>9</sup></code></li>
<li>No two start events will happen at the same timestamp.</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ tags:
<pre>
<strong>Input:</strong> n = 3
<strong>Output:</strong> 5
<strong>Explanation:</strong> The five different ways are show above.
<strong>Explanation:</strong> The five different ways are shown above.
</pre>

<p><strong class="example">Example 2:</strong></p>
Expand Down
20 changes: 18 additions & 2 deletions solution/0700-0799/0799.Champagne Tower/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,35 +27,51 @@ tags:
<p>Now after pouring some non-negative integer cups of champagne, return how full the <code>j<sup>th</sup></code> glass in the <code>i<sup>th</sup></code> row is (both <code>i</code> and <code>j</code> are 0-indexed.)</p>

<p>&nbsp;</p>

<p><strong class="example">Example 1:</strong></p>

<pre>

<strong>Input:</strong> poured = 1, query_row = 1, query_glass = 1

<strong>Output:</strong> 0.00000

<strong>Explanation:</strong> We poured 1 cup of champange to the top glass of the tower (which is indexed as (0, 0)). There will be no excess liquid so all the glasses under the top glass will remain empty.

</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>

<strong>Input:</strong> poured = 2, query_row = 1, query_glass = 1

<strong>Output:</strong> 0.50000

<strong>Explanation:</strong> We poured 2 cups of champange to the top glass of the tower (which is indexed as (0, 0)). There is one cup of excess liquid. The glass indexed as (1, 0) and the glass indexed as (1, 1) will share the excess liquid equally, and each will get half cup of champange.

</pre>

<p><strong class="example">Example 3:</strong></p>

<pre>

<strong>Input:</strong> poured = 100000009, query_row = 33, query_glass = 17

<strong>Output:</strong> 1.00000

</pre>

<p>&nbsp;</p>

<p><strong>Constraints:</strong></p>

<ul>
<li><code>0 &lt;=&nbsp;poured &lt;= 10<sup>9</sup></code></li>
<li><code>0 &lt;= query_glass &lt;= query_row&nbsp;&lt; 100</code></li>

<li><code>0 &lt;=&nbsp;poured &lt;= 10<sup>9</sup></code></li>

<li><code>0 &lt;= query_glass &lt;= query_row&nbsp;&lt; 100</code></li>

</ul>

<!-- description:end -->
Expand Down
2 changes: 2 additions & 0 deletions solution/0800-0899/0819.Most Common Word/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ tags:

<p><code>paragraph</code> 中的单词 <strong>不区分大小写</strong> ,答案应以 <strong>小写 </strong>形式返回。</p>

<p><b>注意</b>&nbsp;单词不包含标点符号。</p>

<p>&nbsp;</p>

<p><strong class="example">示例 1:</strong></p>
Expand Down
13 changes: 12 additions & 1 deletion solution/1100-1199/1108.Defanging an IP Address/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,29 @@ tags:
<p>A <em>defanged&nbsp;IP address</em>&nbsp;replaces every period <code>&quot;.&quot;</code> with <code>&quot;[.]&quot;</code>.</p>

<p>&nbsp;</p>

<p><strong class="example">Example 1:</strong></p>

<pre><strong>Input:</strong> address = "1.1.1.1"

<strong>Output:</strong> "1[.]1[.]1[.]1"

</pre><p><strong class="example">Example 2:</strong></p>

<pre><strong>Input:</strong> address = "255.100.50.0"

<strong>Output:</strong> "255[.]100[.]50[.]0"

</pre>

<p>&nbsp;</p>

<p><strong>Constraints:</strong></p>

<ul>
<li>The given <code>address</code> is a valid IPv4 address.</li>

<li>The given <code>address</code> is a valid IPv4 address.</li>

</ul>

<!-- description:end -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,25 @@ tags:
<p>A string is a <em>valid parentheses string</em>&nbsp;(denoted VPS) if and only if it consists of <code>&quot;(&quot;</code> and <code>&quot;)&quot;</code> characters only, and:</p>

<ul>
<li>It is the empty string, or</li>
<li>It can be written as&nbsp;<code>AB</code>&nbsp;(<code>A</code>&nbsp;concatenated with&nbsp;<code>B</code>), where&nbsp;<code>A</code>&nbsp;and&nbsp;<code>B</code>&nbsp;are VPS&#39;s, or</li>
<li>It can be written as&nbsp;<code>(A)</code>, where&nbsp;<code>A</code>&nbsp;is a VPS.</li>

<li>It is the empty string, or</li>

<li>It can be written as&nbsp;<code>AB</code>&nbsp;(<code>A</code>&nbsp;concatenated with&nbsp;<code>B</code>), where&nbsp;<code>A</code>&nbsp;and&nbsp;<code>B</code>&nbsp;are VPS&#39;s, or</li>

<li>It can be written as&nbsp;<code>(A)</code>, where&nbsp;<code>A</code>&nbsp;is a VPS.</li>

</ul>

<p>We can&nbsp;similarly define the <em>nesting depth</em> <code>depth(S)</code> of any VPS <code>S</code> as follows:</p>

<ul>
<li><code>depth(&quot;&quot;) = 0</code></li>
<li><code>depth(A + B) = max(depth(A), depth(B))</code>, where <code>A</code> and <code>B</code> are VPS&#39;s</li>
<li><code>depth(&quot;(&quot; + A + &quot;)&quot;) = 1 + depth(A)</code>, where <code>A</code> is a VPS.</li>

<li><code>depth(&quot;&quot;) = 0</code></li>

<li><code>depth(A + B) = max(depth(A), depth(B))</code>, where <code>A</code> and <code>B</code> are VPS&#39;s</li>

<li><code>depth(&quot;(&quot; + A + &quot;)&quot;) = 1 + depth(A)</code>, where <code>A</code> is a VPS.</li>

</ul>

<p>For example,&nbsp; <code>&quot;&quot;</code>,&nbsp;<code>&quot;()()&quot;</code>, and&nbsp;<code>&quot;()(()())&quot;</code>&nbsp;are VPS&#39;s (with nesting depths 0, 1, and 2), and <code>&quot;)(&quot;</code> and <code>&quot;(()&quot;</code> are not VPS&#39;s.</p>
Expand Down
32 changes: 25 additions & 7 deletions solution/1100-1199/1138.Alphabet Board Path/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,31 +28,49 @@ tags:
<p>We may make the following moves:</p>

<ul>
<li><code>&#39;U&#39;</code> moves our position up one row, if the position exists on the board;</li>
<li><code>&#39;D&#39;</code> moves our position down one row, if the position exists on the board;</li>
<li><code>&#39;L&#39;</code> moves our position left one column, if the position exists on the board;</li>
<li><code>&#39;R&#39;</code> moves our position right one column, if the position exists on the board;</li>
<li><code>&#39;!&#39;</code>&nbsp;adds the character <code>board[r][c]</code> at our current position <code>(r, c)</code>&nbsp;to the&nbsp;answer.</li>

<li><code>&#39;U&#39;</code> moves our position up one row, if the position exists on the board;</li>

<li><code>&#39;D&#39;</code> moves our position down one row, if the position exists on the board;</li>

<li><code>&#39;L&#39;</code> moves our position left one column, if the position exists on the board;</li>

<li><code>&#39;R&#39;</code> moves our position right one column, if the position exists on the board;</li>

<li><code>&#39;!&#39;</code>&nbsp;adds the character <code>board[r][c]</code> at our current position <code>(r, c)</code>&nbsp;to the&nbsp;answer.</li>

</ul>

<p>(Here, the only positions that exist on the board are positions with letters on them.)</p>

<p>Return a sequence of moves that makes our answer equal to <code>target</code>&nbsp;in the minimum number of moves.&nbsp; You may return any path that does so.</p>

<p>&nbsp;</p>

<p><strong class="example">Example 1:</strong></p>

<pre><strong>Input:</strong> target = "leet"

<strong>Output:</strong> "DDR!UURRR!!DDD!"

</pre><p><strong class="example">Example 2:</strong></p>

<pre><strong>Input:</strong> target = "code"

<strong>Output:</strong> "RR!DDRR!UUL!R!"

</pre>

<p>&nbsp;</p>

<p><strong>Constraints:</strong></p>

<ul>
<li><code>1 &lt;= target.length &lt;= 100</code></li>
<li><code>target</code> consists only of English lowercase letters.</li>

<li><code>1 &lt;= target.length &lt;= 100</code></li>

<li><code>target</code> consists only of English lowercase letters.</li>

</ul>

<!-- description:end -->
Expand Down
18 changes: 15 additions & 3 deletions solution/1100-1199/1139.Largest 1-Bordered Square/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,39 @@ tags:
<p>Given a 2D <code>grid</code> of <code>0</code>s and <code>1</code>s, return the number of elements in&nbsp;the largest <strong>square</strong>&nbsp;subgrid that has all <code>1</code>s on its <strong>border</strong>, or <code>0</code> if such a subgrid&nbsp;doesn&#39;t exist in the <code>grid</code>.</p>

<p>&nbsp;</p>

<p><strong class="example">Example 1:</strong></p>

<pre>

<strong>Input:</strong> grid = [[1,1,1],[1,0,1],[1,1,1]]

<strong>Output:</strong> 9

</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>

<strong>Input:</strong> grid = [[1,1,0,0]]

<strong>Output:</strong> 1

</pre>

<p>&nbsp;</p>

<p><strong>Constraints:</strong></p>

<ul>
<li><code>1 &lt;= grid.length &lt;= 100</code></li>
<li><code>1 &lt;= grid[0].length &lt;= 100</code></li>
<li><code>grid[i][j]</code> is <code>0</code> or <code>1</code></li>

<li><code>1 &lt;= grid.length &lt;= 100</code></li>

<li><code>1 &lt;= grid[0].length &lt;= 100</code></li>

<li><code>grid[i][j]</code> is <code>0</code> or <code>1</code></li>

</ul>

<!-- description:end -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@ tags:

<!-- description:start -->

<p>给你一份『词汇表』(字符串数组)&nbsp;<code>words</code>&nbsp;和一张『字母表』(字符串)&nbsp;<code>chars</code>。</p>
<p>给定一个字符串数组&nbsp;<code>words</code>&nbsp;和一个字符串 <code>chars</code>。</p>

<p>假如你可以用&nbsp;<code>chars</code>&nbsp;中的『字母』(字符)拼写出 <code>words</code>&nbsp;中的某个『单词』(字符串),那么我们就认为你掌握了这个单词。</p>
<p>如果字符串可以由 <code>chars</code> 中的字符组成(每个字符在 <strong>每个</strong>&nbsp;<code>words</code> 中只能使用一次),则认为它是好的。</p>

<p>注意:每次拼写(指拼写词汇表中的一个单词)时,<code>chars</code> 中的每个字母都只能用一次。</p>

<p>返回词汇表&nbsp;<code>words</code>&nbsp;中你掌握的所有单词的 <strong>长度之和</strong>。</p>
<p>返回&nbsp;<code>words</code>&nbsp;中所有好的字符串的长度之和。</p>

<p>&nbsp;</p>

Expand Down Expand Up @@ -56,7 +54,7 @@ tags:
<ul>
<li><code>1 &lt;= words.length &lt;= 1000</code></li>
<li><code>1 &lt;= words[i].length, chars.length&nbsp;&lt;= 100</code></li>
<li>所有字符串中都仅包含小写英文字母</li>
<li><code>words[i]</code>&nbsp;和&nbsp;<code>chars</code> 中都仅包含小写英文字母</li>
</ul>

<!-- description:end -->
Expand Down
26 changes: 22 additions & 4 deletions solution/1100-1199/1184.Distance Between Bus Stops/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,17 @@ tags:
<p>Return the shortest distance between the given&nbsp;<code>start</code>&nbsp;and <code>destination</code>&nbsp;stops.</p>

<p>&nbsp;</p>

<p><strong class="example">Example 1:</strong></p>

<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/1100-1199/1184.Distance%20Between%20Bus%20Stops/images/untitled-diagram-1.jpg" style="width: 388px; height: 240px;" /></p>

<pre>

<strong>Input:</strong> distance = [1,2,3,4], start = 0, destination = 1

<strong>Output:</strong> 1

<strong>Explanation:</strong> Distance between 0 and 1 is 1 or 9, minimum is 1.</pre>

<p>&nbsp;</p>
Expand All @@ -41,9 +45,13 @@ tags:
<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/1100-1199/1184.Distance%20Between%20Bus%20Stops/images/untitled-diagram-1-1.jpg" style="width: 388px; height: 240px;" /></p>

<pre>

<strong>Input:</strong> distance = [1,2,3,4], start = 0, destination = 2

<strong>Output:</strong> 3

<strong>Explanation:</strong> Distance between 0 and 2 is 3 or 7, minimum is 3.

</pre>

<p>&nbsp;</p>
Expand All @@ -53,19 +61,29 @@ tags:
<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/1100-1199/1184.Distance%20Between%20Bus%20Stops/images/untitled-diagram-1-2.jpg" style="width: 388px; height: 240px;" /></p>

<pre>

<strong>Input:</strong> distance = [1,2,3,4], start = 0, destination = 3

<strong>Output:</strong> 4

<strong>Explanation:</strong> Distance between 0 and 3 is 6 or 4, minimum is 4.

</pre>

<p>&nbsp;</p>

<p><strong>Constraints:</strong></p>

<ul>
<li><code>1 &lt;= n&nbsp;&lt;= 10^4</code></li>
<li><code>distance.length == n</code></li>
<li><code>0 &lt;= start, destination &lt; n</code></li>
<li><code>0 &lt;= distance[i] &lt;= 10^4</code></li>

<li><code>1 &lt;= n&nbsp;&lt;= 10^4</code></li>

<li><code>distance.length == n</code></li>

<li><code>0 &lt;= start, destination &lt; n</code></li>

<li><code>0 &lt;= distance[i] &lt;= 10^4</code></li>

</ul>

<!-- description:end -->
Expand Down
Loading
Loading