Skip to content
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
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
*.iml
__pycache__
/node_modules
/solution/result.json
/solution/__pycache__
/solution/.env
.cache
!.cache/plugin/
!.cache/plugin/git-committers/
!.cache/plugin/git-committers/page-authors.json
!.cache/plugin/git-committers/page-authors.json
2 changes: 1 addition & 1 deletion solution/0000-0099/0045.Jump Game II/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ tags:

<!-- description:start -->

<p>给定一个长度为 <code>n</code> 的 <strong>0 索引</strong>整数数组 <code>nums</code>。初始位置为 <code>nums[0]</code>。</p>
<p>给定一个长度为 <code>n</code> 的 <strong>0 索引</strong>整数数组 <code>nums</code>。初始位置在下标 0。</p>

<p>每个元素 <code>nums[i]</code> 表示从索引 <code>i</code> 向后跳转的最大长度。换句话说,如果你在索引&nbsp;<code>i</code>&nbsp;处,你可以跳转到任意 <code>(i + j)</code> 处:</p>

Expand Down
8 changes: 8 additions & 0 deletions solution/0000-0099/0056.Merge Intervals/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ tags:
<strong>输出:</strong>[[1,5]]
<strong>解释:</strong>区间 [1,4] 和 [4,5] 可被视为重叠区间。</pre>

<p><strong class="example">示例 3:</strong></p>

<pre>
<b>输入:</b>intervals = [[4,7],[1,4]]
<b>输出:</b>[[1,7]]
<b>解释:</b>区间 [1,4] 和 [4,7] 可被视为重叠区间。
</pre>

<p>&nbsp;</p>

<p><strong>提示:</strong></p>
Expand Down
8 changes: 8 additions & 0 deletions solution/0000-0099/0056.Merge Intervals/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ tags:
<strong>Explanation:</strong> Intervals [1,4] and [4,5] are considered overlapping.
</pre>

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

<pre>
<strong>Input:</strong> intervals = [[4,7],[1,4]]
<strong>Output:</strong> [[1,7]]
<strong>Explanation:</strong> Intervals [1,4] and [4,7] are considered overlapping.
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

Expand Down
8 changes: 4 additions & 4 deletions solution/0100-0199/0130.Surrounded Regions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ tags:
<p><strong class="example">示例 1:</strong></p>

<div class="example-block">
<p><strong>输入:</strong><span class="example-io">board = [["X","X","X","X"],["X","O","O","X"],["X","X","O","X"],["X","O","X","X"]]</span></p>
<p><strong>输入:</strong><span class="example-io">board = [['X','X','X','X'],['X','O','O','X'],['X','X','O','X'],['X','O','X','X']]</span></p>

<p><b>输出:</b><span class="example-io">[["X","X","X","X"],["X","X","X","X"],["X","X","X","X"],["X","O","X","X"]]</span></p>
<p><b>输出:</b><span class="example-io">[['X','X','X','X'],['X','X','X','X'],['X','X','X','X'],['X','O','X','X']]</span></p>

<p><strong>解释:</strong></p>
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0100-0199/0130.Surrounded%20Regions/images/1718167191-XNjUTG-image.png" style="width: 367px; height: 158px;" />
Expand All @@ -49,9 +49,9 @@ tags:
<p><strong class="example">示例 2:</strong></p>

<div class="example-block">
<p><strong>输入:</strong><span class="example-io">board = [["X"]]</span></p>
<p><strong>输入:</strong><span class="example-io">board = [['X']]</span></p>

<p><strong>输出:</strong><span class="example-io">[["X"]]</span></p>
<p><strong>输出:</strong><span class="example-io">[['X']]</span></p>
</div>

<p>&nbsp;</p>
Expand Down
24 changes: 12 additions & 12 deletions solution/0200-0299/0200.Number of Islands/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@ tags:

<!-- description:start -->

<p>给你一个由 <code>'1'</code>(陆地)和 <code>'0'</code>(水)组成的的二维网格,请你计算网格中岛屿的数量。</p>
<p>给你一个由&nbsp;<code>'1'</code>(陆地)和 <code>'0'</code>(水)组成的的二维网格,请你计算网格中岛屿的数量。</p>

<p>岛屿总是被水包围,并且每座岛屿只能由水平方向和/或竖直方向上相邻的陆地连接形成。</p>

<p>此外,你可以假设该网格的四条边均被水包围。</p>

<p> </p>
<p>&nbsp;</p>

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

<pre>
<strong>输入:</strong>grid = [
["1","1","1","1","0"],
["1","1","0","1","0"],
["1","1","0","0","0"],
["0","0","0","0","0"]
&nbsp; ['1','1','1','1','0'],
&nbsp; ['1','1','0','1','0'],
&nbsp; ['1','1','0','0','0'],
&nbsp; ['0','0','0','0','0']
]
<strong>输出:</strong>1
</pre>
Expand All @@ -44,22 +44,22 @@ tags:

<pre>
<strong>输入:</strong>grid = [
["1","1","0","0","0"],
["1","1","0","0","0"],
["0","0","1","0","0"],
["0","0","0","1","1"]
&nbsp; ['1','1','0','0','0'],
&nbsp; ['1','1','0','0','0'],
&nbsp; ['0','0','1','0','0'],
&nbsp; ['0','0','0','1','1']
]
<strong>输出:</strong>3
</pre>

<p> </p>
<p>&nbsp;</p>

<p><strong>提示:</strong></p>

<ul>
<li><code>m == grid.length</code></li>
<li><code>n == grid[i].length</code></li>
<li><code>1 <= m, n <= 300</code></li>
<li><code>1 &lt;= m, n &lt;= 300</code></li>
<li><code>grid[i][j]</code> 的值为 <code>'0'</code> 或 <code>'1'</code></li>
</ul>

Expand Down
5 changes: 4 additions & 1 deletion solution/0200-0299/0223.Rectangle Area/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ tags:
<p><strong>提示:</strong></p>

<ul>
<li><code>-10<sup>4</sup> &lt;= ax1, ay1, ax2, ay2, bx1, by1, bx2, by2 &lt;= 10<sup>4</sup></code></li>
<li><code>-10<sup>4</sup> &lt;= ax1 &lt;= ax2 &lt;= 10<sup>4</sup></code></li>
<li><code>-10<sup>4</sup> &lt;= ay1 &lt;= ay2 &lt;= 10<sup>4</sup></code></li>
<li><code>-10<sup>4</sup> &lt;= bx1 &lt;= bx2 &lt;= 10<sup>4</sup></code></li>
<li><code>-10<sup>4</sup> &lt;= by1 &lt;= by2 &lt;= 10<sup>4</sup></code></li>
</ul>

<!-- description:end -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ tags:
<pre>
<strong>输入:</strong>nums = [2,1,5,0,4,6]
<strong>输出:</strong>true
<strong>解释:</strong>三元组 (3, 4, 5) 满足题意,因为 nums[3] == 0 &lt; nums[4] == 4 &lt; nums[5] == 6
<strong>解释:</strong>其中一个满足题意的三元组是 (3, 4, 5),因为 nums[3] == 0 &lt; nums[4] == 4 &lt; nums[5] == 6
</pre>

<p>&nbsp;</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ tags:
<pre>
<strong>Input:</strong> nums = [2,1,5,0,4,6]
<strong>Output:</strong> true
<strong>Explanation:</strong> The triplet (3, 4, 5) is valid because nums[3] == 0 &lt; nums[4] == 4 &lt; nums[5] == 6.
<strong>Explanation:</strong> One of the valid triplet is (3, 4, 5), because nums[3] == 0 &lt; nums[4] == 4 &lt; nums[5] == 6.
</pre>

<p>&nbsp;</p>
Expand Down
39 changes: 25 additions & 14 deletions solution/0300-0399/0347.Top K Frequent Elements/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,34 +25,45 @@ tags:

<p>给你一个整数数组 <code>nums</code> 和一个整数 <code>k</code> ,请你返回其中出现频率前 <code>k</code> 高的元素。你可以按 <strong>任意顺序</strong> 返回答案。</p>

<p> </p>
<p>&nbsp;</p>

<p><strong>示例 1:</strong></p>
<p><strong class="example">示例 1</strong></p>

<pre>
<strong>输入: </strong>nums = [1,1,1,2,2,3], k = 2
<strong>输出: </strong>[1,2]
</pre>
<div class="example-block">
<p><span class="example-io"><b>输入:</b>nums = [1,1,1,2,2,3], k = 2</span></p>

<p><strong>示例 2:</strong></p>
<p><strong>输出:</strong><span class="example-io">[1,2]</span></p>
</div>

<pre>
<strong>输入: </strong>nums = [1], k = 1
<strong>输出: </strong>[1]</pre>
<p><strong class="example">示例 2:</strong></p>

<p> </p>
<div class="example-block">
<p><span class="example-io"><b>输入:</b>nums = [1], k = 1</span></p>

<p><span class="example-io"><b>输出:</b>[1]</span></p>
</div>

<p><strong class="example">示例 3:</strong></p>

<div class="example-block">
<p><span class="example-io"><b>输入:</b>nums = [1,2,1,2,1,2,3,1,3,2], k = 2</span></p>

<p><strong>输出:</strong><span class="example-io">[1,2]</span></p>
</div>

<p>&nbsp;</p>

<p><strong>提示:</strong></p>

<ul>
<li><code>1 <= nums.length <= 10<sup>5</sup></code></li>
<li><code>1 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
<li><code>k</code> 的取值范围是 <code>[1, 数组中不相同的元素的个数]</code></li>
<li>题目数据保证答案唯一,换句话说,数组中前 <code>k</code> 个高频元素的集合是唯一的</li>
</ul>

<p> </p>
<p>&nbsp;</p>

<p><strong>进阶:</strong>你所设计算法的时间复杂度 <strong>必须</strong> 优于 <code>O(n log n)</code> ,其中 <code>n</code><em> </em>是数组大小。</p>
<p><strong>进阶:</strong>你所设计算法的时间复杂度 <strong>必须</strong> 优于 <code>O(n log n)</code> ,其中 <code>n</code><em>&nbsp;</em>是数组大小。</p>

<!-- description:end -->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ tags:
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">nums = [1,2,1,2,1,2,3,1,3,2], k = 2</span></p>

<p><strong>Output:</strong> <span class="example-io">[-1]</span></p>
<p><strong>Output:</strong> <span class="example-io">[1,2]</span></p>
</div>

<p>&nbsp;</p>
Expand Down
29 changes: 21 additions & 8 deletions solution/0400-0499/0499.The Maze III/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,29 @@ tags:
<img src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0400-0499/0499.The%20Maze%20III/images/maze_2_example_2.png" style="width: 100%;" />
</pre>

<p>&nbsp;</p>
<p><strong class="example">示例 3:</strong></p>

<p><strong>注意:</strong></p>
<pre>
<strong>输入:</strong>maze = [[0,0,0,0,0,0,0],[0,0,1,0,0,1,0],[0,0,0,0,1,0,0],[0,0,0,0,0,0,1]], ball = [0,4], hole = [3,5]
<b>输出:</b>"dldr"
</pre>

<p>&nbsp;</p>

<ol>
<li>迷宫中只有一个球和一个目的地。</li>
<li>球和洞都在空地上,且初始时它们不在同一位置。</li>
<li>给定的迷宫不包括边界 (如图中的红色矩形), 但你可以假设迷宫的边缘都是墙壁。</li>
<li>迷宫至少包括2块空地,行数和列数均不超过30。</li>
</ol>
<p><strong>提示:</strong></p>

<ul>
<li><code>m == maze.length</code></li>
<li><code>n == maze[i].length</code></li>
<li><code>1 &lt;= m, n &lt;= 100</code></li>
<li><code>maze[i][j]</code> is <code>0</code> or <code>1</code>.</li>
<li><code>ball.length == 2</code></li>
<li><code>hole.length == 2</code></li>
<li><code>0 &lt;= ball<sub>row</sub>, hole<sub>row</sub> &lt;= m</code></li>
<li><code>0 &lt;= ball<sub>col</sub>, hole<sub>col</sub> &lt;= n</code></li>
<li>球和洞都存在于一个空地中,它们最初不会处于同一位置。</li>
<li>迷宫中至少有 <code>2</code> 个空地。</li>
</ul>

<!-- description:end -->

Expand Down
44 changes: 23 additions & 21 deletions solution/1100-1199/1181.Before and After Puzzle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,33 +37,35 @@ tags:

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

<pre><strong>输入:</strong>phrases = [&quot;writing code&quot;,&quot;code rocks&quot;]
<strong>输出:</strong>[&quot;writing code rocks&quot;]
</pre>
<div class="example-block">
<p><strong>输入:</strong>phrases = ["writing code","code rocks"]</p>

<p><strong>输出:</strong>["writing code rocks"]</p>
</div>

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

<pre><strong>输入:</strong>phrases = [&quot;mission statement&quot;,
&quot;a quick bite to eat&quot;,
&nbsp; &quot;a chip off the old block&quot;,
&nbsp; &quot;chocolate bar&quot;,
&nbsp; &quot;mission impossible&quot;,
&nbsp; &quot;a man on a mission&quot;,
&nbsp; &quot;block party&quot;,
&nbsp; &quot;eat my words&quot;,
&nbsp; &quot;bar of soap&quot;]
<strong>输出:</strong>[&quot;a chip off the old block party&quot;,
&nbsp; &quot;a man on a mission impossible&quot;,
&nbsp; &quot;a man on a mission statement&quot;,
&nbsp; &quot;a quick bite to eat my words&quot;,
&quot;chocolate bar of soap&quot;]
</pre>
<div class="example-block">
<p><strong>输入:</strong>phrases = ["mission statement", "a quick bite to eat", &nbsp; "a chip off the old block", &nbsp; "chocolate bar", &nbsp; "mission impossible", &nbsp; "a man on a mission", &nbsp; "block party", &nbsp; "eat my words", &nbsp; "bar of soap"]</p>

<p><strong>输出:</strong>["a chip off the old block party", &nbsp; "a man on a mission impossible", &nbsp; "a man on a mission statement", &nbsp; "a quick bite to eat my words", "chocolate bar of soap"]</p>
</div>

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

<pre><strong>输入:</strong>phrases = [&quot;a&quot;,&quot;b&quot;,&quot;a&quot;]
<strong>输出:</strong>[&quot;a&quot;]
</pre>
<div class="example-block">
<p><strong>输入:</strong>phrases = ["a","b","a"]</p>

<p><strong>输出:</strong>["a"]</p>
</div>

<p><strong class="example">示例 4:</strong></p>

<div class="example-block">
<p><span class="example-io"><b>输入:</b>phrases = ["ab ba","ba ab","ab ba"]</span></p>

<p><span class="example-io"><b>输出:</b>["ab ba ab","ba ab ba"]</span></p>
</div>

<p>&nbsp;</p>

Expand Down
51 changes: 25 additions & 26 deletions solution/1100-1199/1181.Before and After Puzzle/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,45 +25,44 @@ tags:

<p>A <em>phrase</em> is a string that consists of lowercase English letters and spaces only. No space appears in the start or the end of a phrase. There are&nbsp;no consecutive spaces&nbsp;in a phrase.</p>

<p><em>Before and After&nbsp;puzzles</em> are phrases that are formed by merging&nbsp;two phrases where the <strong>last&nbsp;word of the first&nbsp;phrase</strong> is the same as the <strong>first word of the second phrase</strong>.</p>
<p><em>Before and After&nbsp;puzzles</em> are phrases that are formed by merging&nbsp;two phrases where the <strong>last&nbsp;word of the first&nbsp;phrase</strong> is the same as the <strong>first word of the second phrase</strong>. Note that only the <em>last word of the first phrase</em> and the <em>first word of the second phrase</em> are merged in this process.</p>

<p>Return the&nbsp;Before and After&nbsp;puzzles that can be formed by every two phrases&nbsp;<code>phrases[i]</code>&nbsp;and&nbsp;<code>phrases[j]</code>&nbsp;where&nbsp;<code>i != j</code>. Note that the order of matching two phrases matters, we want to consider both orders.</p>

<p>You should return a list of&nbsp;<strong>distinct</strong>&nbsp;strings <strong>sorted&nbsp;lexicographically</strong>.</p>
<p>You should return a list of&nbsp;<strong>distinct</strong>&nbsp;strings <strong>sorted&nbsp;lexicographically</strong>, after removing all <em>duplicate</em> phrases in the generated Before and After puzzles.</p>

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

<pre>
<strong>Input:</strong> phrases = [&quot;writing code&quot;,&quot;code rocks&quot;]
<strong>Output:</strong> [&quot;writing code rocks&quot;]
</pre>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">phrases = [&quot;writing code&quot;,&quot;code rocks&quot;]</span></p>

<p><strong>Output:</strong> <span class="example-io">[&quot;writing code rocks&quot;]</span></p>
</div>

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

<pre>
<strong>Input:</strong> phrases = [&quot;mission statement&quot;,
&quot;a quick bite to eat&quot;,
&nbsp; &quot;a chip off the old block&quot;,
&nbsp; &quot;chocolate bar&quot;,
&nbsp; &quot;mission impossible&quot;,
&nbsp; &quot;a man on a mission&quot;,
&nbsp; &quot;block party&quot;,
&nbsp; &quot;eat my words&quot;,
&nbsp; &quot;bar of soap&quot;]
<strong>Output:</strong> [&quot;a chip off the old block party&quot;,
&nbsp; &quot;a man on a mission impossible&quot;,
&nbsp; &quot;a man on a mission statement&quot;,
&nbsp; &quot;a quick bite to eat my words&quot;,
&quot;chocolate bar of soap&quot;]
</pre>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">phrases = [&quot;mission statement&quot;,&quot;a quick bite to eat&quot;,&quot;a chip off the old block&quot;,&quot;chocolate bar&quot;,&quot;mission impossible&quot;,&quot;a man on a mission&quot;,&quot;block party&quot;,&quot;eat my words&quot;,&quot;bar of soap&quot;]</span></p>

<p><strong>Output:</strong> <span class="example-io">[&quot;a chip off the old block party&quot;,&quot;a man on a mission impossible&quot;,&quot;a man on a mission statement&quot;,&quot;a quick bite to eat my words&quot;,&quot;chocolate bar of soap&quot;]</span></p>
</div>

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

<pre>
<strong>Input:</strong> phrases = [&quot;a&quot;,&quot;b&quot;,&quot;a&quot;]
<strong>Output:</strong> [&quot;a&quot;]
</pre>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">phrases = [&quot;a&quot;,&quot;b&quot;,&quot;a&quot;]</span></p>

<p><strong>Output:</strong> <span class="example-io">[&quot;a&quot;]</span></p>
</div>

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

<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">phrases = [&quot;ab ba&quot;,&quot;ba ab&quot;,&quot;ab ba&quot;]</span></p>

<p><strong>Output:</strong> <span class="example-io">[&quot;ab ba ab&quot;,&quot;ba ab ba&quot;]</span></p>
</div>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
Expand Down
Loading