Skip to content

feat: add new lc problems #4467

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
Jun 8, 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
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
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,23 @@ tags:
<pre>
<strong>输入:</strong>s1 = "parker", s2 = "morris", baseStr = "parser"
<strong>输出:</strong>"makkek"
<strong>解释:</strong>根据 <code>A</code> 和 <code>B 中的等价信息,</code>我们可以将这些字符分为 <code>[m,p]</code>, <code>[a,o]</code>, <code>[k,r,s]</code>, <code>[e,i] 共 4 组</code>。每组中的字符都是等价的,并按字典序排列。所以答案是 <code>"makkek"</code>。
<strong>解释:</strong>根据 <code>A</code> 和 <code>B</code> 中的等价信息,我们可以将这些字符分为 <code>[m,p]</code>, <code>[a,o]</code>, <code>[k,r,s]</code>, <code>[e,i]</code> 共 4 组。每组中的字符都是等价的,并按字典序排列。所以答案是 <code>"makkek"</code>。
</pre>

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

<pre>
<strong>输入:</strong>s1 = "hello", s2 = "world", baseStr = "hold"
<strong>输出:</strong>"hdld"
<strong>解释:</strong>根据 <code>A</code> 和 <code>B 中的等价信息,</code>我们可以将这些字符分为 <code>[h,w]</code>, <code>[d,e,o]</code>, <code>[l,r] 共 3 组</code>。所以只有 S 中的第二个字符 <code>'o'</code> 变成 <code>'d',最后答案为 </code><code>"hdld"</code>。
<strong>解释:</strong>根据 <code>A</code> 和 <code>B</code> 中的等价信息,我们可以将这些字符分为 <code>[h,w]</code>, <code>[d,e,o]</code>, <code>[l,r]</code> 共 3 组。所以只有 S 中的第二个字符 <code>'o'</code> 变成 <code>'d'</code>,最后答案为 <code>"hdld"</code>。
</pre>

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

<pre>
<strong>输入:</strong>s1 = "leetcode", s2 = "programs", baseStr = "sourcecode"
<strong>输出:</strong>"aauaaaaada"
<strong>解释:</strong>我们可以把 AB 中的等价字符分为 <code>[a,o,e,r,s,c]</code>, <code>[l,p]</code>, <code>[g,t]</code> 和 <code>[d,m] 共 4 组</code>,因此 <code>S</code> 中除了 <code>'u'</code> 和 <code>'d'</code> 之外的所有字母都转化成了 <code>'a'</code>,最后答案为 <code>"aauaaaaada"</code>。
<strong>解释:</strong>我们可以把 <code>A</code><code>B</code> 中的等价字符分为 <code>[a,o,e,r,s,c]</code>, <code>[l,p]</code>, <code>[g,t]</code> 和 <code>[d,m]</code> 共 4 组,因此 <code>S</code> 中除了 <code>'u'</code> 和 <code>'d'</code> 之外的所有字母都转化成了 <code>'a'</code>,最后答案为 <code>"aauaaaaada"</code>。
</pre>

<p>&nbsp;</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ tags:
(sale_id, year) 是这张表的主键(具有唯一值的列的组合)。
product_id 是产品表的外键(reference 列)。
这张表的每一行都表示:编号 product_id 的产品在某一年的销售额。
一个产品可能在同一年内有多个销售条目。
请注意,价格是按每单位计的。
</pre>

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
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