Skip to content

Commit

Permalink
feat: update lc problems
Browse files Browse the repository at this point in the history
  • Loading branch information
yanglbme committed Jan 30, 2025
1 parent a1122bc commit 1f3a080
Show file tree
Hide file tree
Showing 49 changed files with 176 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ tags:
<ul>
<li><code>2 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
<li><code>-30 &lt;= nums[i] &lt;= 30</code></li>
<li><strong>保证</strong> 数组&nbsp;<code>nums</code>之中任意元素的全部前缀元素和后缀的乘积都在&nbsp; <strong>32 位</strong> 整数范围内</li>
<li>输入&nbsp;<strong>保证</strong> 数组&nbsp;<code>answer[i]</code>&nbsp;在&nbsp; <strong>32 位</strong> 整数范围内</li>
</ul>

<p>&nbsp;</p>
Expand Down
14 changes: 8 additions & 6 deletions solution/0500-0599/0554.Brick Wall/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ tags:

<p>给你一个二维数组 <code>wall</code> ,该数组包含这堵墙的相关信息。其中,<code>wall[i]</code> 是一个代表从左至右每块砖的宽度的数组。你需要找出怎样画才能使这条线 <strong>穿过的砖块数量最少</strong> ,并且返回 <strong>穿过的砖块数量</strong> 。</p>

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

<p><strong>示例 1:</strong></p>
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0500-0599/0554.Brick%20Wall/images/cutwall-grid.jpg" style="width: 493px; height: 577px;" />
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0500-0599/0554.Brick%20Wall/images/a.png" style="width: 400px; height: 384px;" />
<pre>
<strong>输入:</strong>wall = [[1,2,2,1],[3,1,2],[1,3,2],[2,4],[3,1,2],[1,3,1,1]]
<strong>输出:</strong>2
Expand All @@ -39,15 +39,17 @@ tags:
<strong>输出:</strong>3
</pre>

&nbsp;

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

<ul>
<li><code>n == wall.length</code></li>
<li><code>1 <= n <= 10<sup>4</sup></code></li>
<li><code>1 <= wall[i].length <= 10<sup>4</sup></code></li>
<li><code>1 <= sum(wall[i].length) <= 2 * 10<sup>4</sup></code></li>
<li><code>1 &lt;= n &lt;= 10<sup>4</sup></code></li>
<li><code>1 &lt;= wall[i].length &lt;= 10<sup>4</sup></code></li>
<li><code>1 &lt;= sum(wall[i].length) &lt;= 2 * 10<sup>4</sup></code></li>
<li>对于每一行 <code>i</code> ,<code>sum(wall[i])</code> 是相同的</li>
<li><code>1 <= wall[i][j] <= 2<sup>31</sup> - 1</code></li>
<li><code>1 &lt;= wall[i][j] &lt;= 2<sup>31</sup> - 1</code></li>
</ul>

<!-- description:end -->
Expand Down
1 change: 1 addition & 0 deletions solution/0900-0999/0906.Super Palindromes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ difficulty: 困难
edit_url: https://github.com/doocs/leetcode/edit/main/solution/0900-0999/0906.Super%20Palindromes/README.md
tags:
- 数学
- 字符串
- 枚举
---

Expand Down
1 change: 1 addition & 0 deletions solution/0900-0999/0906.Super Palindromes/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ difficulty: Hard
edit_url: https://github.com/doocs/leetcode/edit/main/solution/0900-0999/0906.Super%20Palindromes/README_EN.md
tags:
- Math
- String
- Enumeration
---

Expand Down
2 changes: 1 addition & 1 deletion solution/1000-1099/1023.Camelcase Matching/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ tags:

<p>给你一个字符串数组 <code>queries</code>,和一个表示模式的字符串&nbsp;<code>pattern</code>,请你返回一个布尔数组 <code>answer</code> 。只有在待查项&nbsp;<code>queries[i]</code> 与模式串&nbsp;<code>pattern</code> 匹配时,&nbsp;<code>answer[i]</code>&nbsp;才为 <code>true</code>,否则为 <code>false</code>。</p>

<p>如果可以将<strong>小写字母</strong>插入模式串&nbsp;<code>pattern</code>&nbsp;得到待查询项&nbsp;<code>queries[i]</code>,那么待查询项与给定模式串匹配。可以在任何位置插入每个字符,也可以不插入字符。</p>
<p>如果可以将&nbsp;<strong>小写字母&nbsp;</strong>插入模式串&nbsp;<code>pattern</code>&nbsp;得到待查询项&nbsp;<code>queries[i]</code>,那么待查询项与给定模式串匹配。您可以在模式串中的任何位置插入字符,也可以选择不插入任何字符。</p>

<p>&nbsp;</p>

Expand Down
2 changes: 1 addition & 1 deletion solution/1000-1099/1023.Camelcase Matching/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ tags:

<p>Given an array of strings <code>queries</code> and a string <code>pattern</code>, return a boolean array <code>answer</code> where <code>answer[i]</code> is <code>true</code> if <code>queries[i]</code> matches <code>pattern</code>, and <code>false</code> otherwise.</p>

<p>A query word <code>queries[i]</code> matches <code>pattern</code> if you can insert lowercase English letters pattern so that it equals the query. You may insert each character at any position and you may not insert any characters.</p>
<p>A query word <code>queries[i]</code> matches <code>pattern</code> if you can insert lowercase English letters into the pattern so that it equals the query. You may insert a character at any position in pattern or you may choose not to insert any characters <strong>at all</strong>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
Expand Down
2 changes: 2 additions & 0 deletions solution/1100-1199/1183.Maximum Number of Ones/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ rating: 2366
source: 第 8 场双周赛 Q4
tags:
- 贪心
- 数学
- 排序
- 堆(优先队列)
---

Expand Down
2 changes: 2 additions & 0 deletions solution/1100-1199/1183.Maximum Number of Ones/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ rating: 2366
source: Biweekly Contest 8 Q4
tags:
- Greedy
- Math
- Sorting
- Heap (Priority Queue)
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ tags:

<!-- description:start -->

<p>给你一个字符串 <code>s</code>&nbsp;和一个整数 <code>k</code>&nbsp;。请你用 <code>s</code>&nbsp;字符串中 <strong>所有字符</strong>&nbsp;构造 <code>k</code>&nbsp;个非空 <span data-keyword="palindrome-string">回文串</span>&nbsp;。</p>
<p>给你一个字符串 <code>s</code>&nbsp;和一个整数 <code>k</code>&nbsp;。请你用 <code>s</code>&nbsp;字符串中 <strong>所有字符</strong>&nbsp;构造 <code>k</code>&nbsp;个<strong>非空</strong> <span data-keyword="palindrome-string">回文串</span>&nbsp;。</p>

<p>如果你可以用&nbsp;<code>s</code>&nbsp;中所有字符构造&nbsp;<code>k</code>&nbsp;个回文字符串,那么请你返回 <strong>True</strong>&nbsp;,否则返回&nbsp;<strong>False</strong>&nbsp;。</p>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ tags:
- 数组
- 动态规划
- 矩阵
- 前缀和
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ tags:
- Array
- Dynamic Programming
- Matrix
- Prefix Sum
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ tags:

<!-- description:start -->

<p>桌面上有 <code>2n</code> 个颜色不完全相同的球,球上的颜色共有 <code>k</code> 种。给你一个大小为 <code>k</code> 的整数数组 <code>balls</code> ,其中 <code>balls[i]</code> 是颜色为&nbsp;<code>i</code> 的球的数量。</p>
<p>桌面上有 <code>2n</code> 个颜色不完全相同的球,球的颜色共有 <code>k</code> 种。给你一个大小为 <code>k</code> 的整数数组 <code>balls</code> ,其中 <code>balls[i]</code> 是颜色为&nbsp;<code>i</code> 的球的数量。</p>

<p>所有的球都已经 <strong>随机打乱顺序</strong> ,前 <code>n</code> 个球放入第一个盒子,后 <code>n</code> 个球放入另一个盒子(请认真阅读示例 2 的解释部分)。</p>

<p><strong>注意:</strong>这两个盒子是不同的。例如,两个球颜色分别为 <code>a</code> 和 <code>b</code>,盒子分别为 <code>[]</code> 和 <code>()</code>,那么 <code>[a] (b)</code> 和 <code>[b] (a)</code> 这两种分配方式是不同的(请认真阅读示例的解释部分)。</p>

<p>请返回「两个盒子中球的颜色数相同」的情况的概率。答案与真实值误差在 <code>10^-5</code> 以内,则被视为正确答案</p>
<p>请返回「两个盒子中球的颜色数相同」的情况的概率。答案与真实值误差在 <code>10<sup>-5</sup></code> 以内,则被视为正确答案</p>

<p>&nbsp;</p>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ tags:
- 数组
- 有序集合
- 前缀和
- 排序
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ tags:
- Array
- Ordered Set
- Prefix Sum
- Sorting
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ tags:
<pre>
<strong>Input:</strong> x = 2, y = 5, z = 1
<strong>Output:</strong> 12
<strong>Explanation: </strong>We can concactenate the strings &quot;BB&quot;, &quot;AA&quot;, &quot;BB&quot;, &quot;AA&quot;, &quot;BB&quot;, and &quot;AB&quot; in that order. Then, our new string is &quot;BBAABBAABBAB&quot;.
<strong>Explanation: </strong>We can concatenate the strings &quot;BB&quot;, &quot;AA&quot;, &quot;BB&quot;, &quot;AA&quot;, &quot;BB&quot;, and &quot;AB&quot; in that order. Then, our new string is &quot;BBAABBAABBAB&quot;.
That string has length 12, and we can show that it is impossible to construct a string of longer length.
</pre>

Expand All @@ -44,7 +44,7 @@ That string has length 12, and we can show that it is impossible to construct a
<pre>
<strong>Input:</strong> x = 3, y = 2, z = 2
<strong>Output:</strong> 14
<strong>Explanation:</strong> We can concactenate the strings &quot;AB&quot;, &quot;AB&quot;, &quot;AA&quot;, &quot;BB&quot;, &quot;AA&quot;, &quot;BB&quot;, and &quot;AA&quot; in that order. Then, our new string is &quot;ABABAABBAABBAA&quot;.
<strong>Explanation:</strong> We can concatenate the strings &quot;AB&quot;, &quot;AB&quot;, &quot;AA&quot;, &quot;BB&quot;, &quot;AA&quot;, &quot;BB&quot;, and &quot;AA&quot; in that order. Then, our new string is &quot;ABABAABBAABBAA&quot;.
That string has length 14, and we can show that it is impossible to construct a string of longer length.
</pre>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ source: 第 351 场周赛 Q2
tags:
- 位运算
- 脑筋急转弯
- 枚举
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ source: Weekly Contest 351 Q2
tags:
- Bit Manipulation
- Brainteaser
- Enumeration
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ tags:
- 数组
- 二分查找
- 矩阵
- 堆(优先队列)
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ tags:
- Array
- Binary Search
- Matrix
- Heap (Priority Queue)
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ tags:
- 数组
- 数学
- 数论
- 排序
- 单调栈
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ tags:
- Array
- Math
- Number Theory
- Sorting
- Monotonic Stack
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ tags:
- 位运算
-
- 深度优先搜索
- 记忆化搜索
- 数组
- 动态规划
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ tags:
- Bit Manipulation
- Tree
- Depth-First Search
- Memoization
- Array
- Dynamic Programming
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ tags:

<!-- description:start -->

<p>给你一个 <strong>下标从 1 开始的</strong> 整数数组&nbsp;<code>prices</code>&nbsp;,其中&nbsp;<code>prices[i]</code>&nbsp;表示你购买第 <code>i</code>&nbsp;个水果需要花费的金币数目。</p>
<p>给你一个 <strong>下标从 0&nbsp;开始的</strong> 整数数组&nbsp;<code>prices</code>&nbsp;,其中&nbsp;<code>prices[i]</code>&nbsp;表示你购买第 <code>i + 1</code>&nbsp;个水果需要花费的金币数目。</p>

<p>水果超市有如下促销活动:</p>

<ul>
<li>如果你花费 <code>prices[i]</code>&nbsp;购买了下标为&nbsp;<code>i</code>&nbsp;的水果,那么你可以免费获得下标范围在&nbsp;<code>[i + 1, i + i]</code>&nbsp;的水果。</li>
<li>如果你花费 <code>prices[i]</code>&nbsp;购买了下标为&nbsp;<code>i + 1</code>&nbsp;的水果,那么你可以免费获得下标范围在&nbsp;<code>[i + 1, i + i]</code>&nbsp;的水果。</li>
</ul>

<p><strong>注意</strong>&nbsp;,即使你&nbsp;<strong>可以</strong>&nbsp;免费获得水果&nbsp;<code>j</code>&nbsp;,你仍然可以花费&nbsp;<code>prices[j]</code>&nbsp;个金币去购买它以获得它的奖励。</p>
<p><strong>注意</strong>&nbsp;,即使你&nbsp;<strong>可以</strong>&nbsp;免费获得水果&nbsp;<code>j</code>&nbsp;,你仍然可以花费&nbsp;<code>prices[j - 1]</code>&nbsp;个金币去购买它以获得它的奖励。</p>

<p>请你返回获得所有水果所需要的 <strong>最少</strong>&nbsp;金币数。</p>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ tags:

<!-- description:start -->

<p>You are given an <strong>1-indexed</strong> integer array <code>prices</code> where <code>prices[i]</code> denotes the number of coins needed to purchase the <code>i<sup>th</sup></code> fruit.</p>
<p>You are given an <strong>0-indexed</strong> integer array <code>prices</code> where <code>prices[i]</code> denotes the number of coins needed to purchase the <code>(i + 1)<sup>th</sup></code> fruit.</p>

<p>The fruit market has the following reward for each fruit:</p>

<ul>
<li>If you purchase the <code>i<sup>th</sup></code> fruit at <code>prices[i]</code> coins, you can get any number of the next <code>i</code> fruits for free.</li>
<li>If you purchase the <code>(i + 1)<sup>th</sup></code> fruit at <code>prices[i]</code> coins, you can get any number of the next <code>i</code> fruits for free.</li>
</ul>

<p><strong>Note</strong> that even if you <strong>can</strong> take fruit <code>j</code> for free, you can still purchase it for <code>prices[j]</code> coins to receive its reward.</p>
<p><strong>Note</strong> that even if you <strong>can</strong> take fruit <code>j</code> for free, you can still purchase it for <code>prices[j - 1]</code> coins to receive its reward.</p>

<p>Return the <strong>minimum</strong> number of coins needed to acquire all the fruits.</p>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ tags:
- 线段树
- 队列
- 数组
- 双指针
- 滑动窗口
- 单调队列
- 单调栈
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ tags:
- Segment Tree
- Queue
- Array
- Two Pointers
- Sliding Window
- Monotonic Queue
- Monotonic Stack
---
Expand Down
27 changes: 13 additions & 14 deletions solution/3400-3499/3421.Find Students Who Improved/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,22 @@ tags:

<p>Scores 表:</p>

<pre class="example-io">
<pre>
+------------+----------+-------+------------+
| student_id | subject | score | exam_date |
+------------+----------+-------+------------+
| 101 | Math | 70 | 15-01-2023 |
| 101 | Math | 85 | 15-02-2023 |
| 101 | Physics | 65 | 15-01-2023 |
| 101 | Physics | 60 | 15-02-2023 |
| 102 | Math | 80 | 15-01-2023 |
| 102 | Math | 85 | 15-02-2023 |
| 103 | Math | 90 | 15-01-2023 |
| 104 | Physics | 75 | 15-01-2023 |
| 104 | Physics | 85 | 15-02-2023 |
+------------+----------+-------+------------+
</pre>

<p><strong>输出:</strong></p>
| 101 | Math | 70 | 2023-01-15 |
| 101 | Math | 85 | 2023-02-15 |
| 101 | Physics | 65 | 2023-01-15 |
| 101 | Physics | 60 | 2023-02-15 |
| 102 | Math | 80 | 2023-01-15 |
| 102 | Math | 85 | 2023-02-15 |
| 103 | Math | 90 | 2023-01-15 |
| 104 | Physics | 75 | 2023-01-15 |
| 104 | Physics | 85 | 2023-02-15 |
+------------+----------+-------+------------+</pre>

<p><strong>出:</strong></p>

<pre class="example-io">
+------------+----------+-------------+--------------+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
comments: true
difficulty: 中等
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3400-3499/3422.Minimum%20Operations%20to%20Make%20Subarray%20Elements%20Equal/README.md
tags:
- 数组
- 哈希表
- 数学
- 滑动窗口
- 堆(优先队列)
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
comments: true
difficulty: Medium
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3400-3499/3422.Minimum%20Operations%20to%20Make%20Subarray%20Elements%20Equal/README_EN.md
tags:
- Array
- Hash Table
- Math
- Sliding Window
- Heap (Priority Queue)
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: 简单
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3400-3499/3423.Maximum%20Difference%20Between%20Adjacent%20Elements%20in%20a%20Circular%20Array/README.md
tags:
- 数组
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: Easy
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3400-3499/3423.Maximum%20Difference%20Between%20Adjacent%20Elements%20in%20a%20Circular%20Array/README_EN.md
tags:
- Array
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
comments: true
difficulty: 中等
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3400-3499/3424.Minimum%20Cost%20to%20Make%20Arrays%20Identical/README.md
tags:
- 贪心
- 数组
- 排序
---

<!-- problem:start -->
Expand Down
Loading

0 comments on commit 1f3a080

Please sign in to comment.