Skip to content

feat: update lc problems #2673

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
Apr 27, 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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[English Version](/solution/0000-0099/0005.Longest%20Palindromic%20Substring/README_EN.md)

<!-- tags:字符串,动态规划 -->
<!-- tags:双指针,字符串,动态规划 -->

## 题目描述

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[中文文档](/solution/0000-0099/0005.Longest%20Palindromic%20Substring/README.md)

<!-- tags:String,Dynamic Programming -->
<!-- tags:Two Pointers,String,Dynamic Programming -->

## Description

Expand Down
48 changes: 32 additions & 16 deletions solution/0200-0299/0281.Zigzag Iterator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,46 @@

<!-- 这里写题目描述 -->

<p>给出两个一维的向量,请你实现一个迭代器,交替返回它们中间的元素。</p>
<p>给出两个整数向量&nbsp;<code>v1</code>&nbsp;和&nbsp;<code>v2</code>,请你实现一个迭代器,交替返回它们中间的元素。</p>

<p><strong>示例:</strong></p>
<p>实现&nbsp;<code>ZigzagIterator</code>&nbsp;类:</p>

<pre><strong>输入:</strong>
v1 = [1,2]
v2 = [3,4,5,6]
<ul>
<li><code>ZigzagIterator(List&lt;int&gt; v1, List&lt;int&gt; v2)</code>&nbsp;用两个向量&nbsp;<code>v1</code>&nbsp;和&nbsp;<code>v2</code>&nbsp;初始化对象。</li>
<li><code>boolean hasNext()</code>&nbsp;如果迭代器还有元素返回&nbsp;<code>true</code>,否则返回 <code>false</code>。</li>
<li><code>int next()</code>&nbsp;返回迭代器的当前元素并将迭代器移动到下一个元素。</li>
</ul>

<strong>输出:</strong> <code>[1,3,2,4,5,6]
<p><strong class="example">示例 1:</strong></p>

<strong>解析:</strong></code>&nbsp;通过连续调用 <em>next</em> 函数直到 <em>hasNext</em> 函数返回 <code>false,</code>
&nbsp; <em>next</em> 函数返回值的次序应依次为: <code>[1,3,2,4,5,6]。</code></pre>
<pre>
<strong>输入:</strong>v1 = [1,2], v2 = [3,4,5,6]
<strong>输出:</strong>[1,3,2,4,5,6]
<strong>解释:</strong>通过重复调用 next 直到 hasNext 返回 false,那么 next 返回的元素的顺序应该是:[1,3,2,4,5,6]。
</pre>

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

<pre>
<strong>输入:</strong>v1 = [1], v2 = []
<strong>输出:</strong>[1]
</pre>

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

<p><strong>拓展:</strong>假如给你&nbsp;<code>k</code>&nbsp;个一维向量呢?你的代码在这种情况下的扩展性又会如何呢?</p>
<pre>
<strong>输入:</strong>v1 = [], v2 = [1]
<strong>输出:</strong>[1]
</pre>

<p><strong>拓展声明:</strong><br>
&nbsp;&ldquo;锯齿&rdquo; 顺序对于&nbsp;<code>k &gt; 2</code>&nbsp;的情况定义可能会有些歧义。所以,假如你觉得 &ldquo;锯齿&rdquo; 这个表述不妥,也可以认为这是一种&nbsp;&ldquo;循环&rdquo;。例如:</p>
<p><strong>拓展:</strong>假如给你&nbsp;<code>k</code>&nbsp;个向量呢?你的代码在这种情况下的扩展性又会如何呢?</p>

<pre><strong>输入:</strong>
[1,2,3]
[4,5,6,7]
[8,9]
<p><strong>拓展声明:</strong><br />
&nbsp;“锯齿” 顺序对于&nbsp;<code>k &gt; 2</code>&nbsp;的情况定义可能会有些歧义。所以,假如你觉得 “锯齿” 这个表述不妥,也可以认为这是一种&nbsp;“循环”。例如:</p>

<strong>输出: </strong><code>[1,4,8,2,5,9,3,6,7]</code>.
<pre>
<strong>输入:</strong>v1 = [1,2,3], v2 = [4,5,6,7], v3 = [8,9]
<strong>输出:</strong>[1,4,8,2,5,9,3,6,7]
</pre>

## 解法
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[English Version](/solution/0600-0699/0642.Design%20Search%20Autocomplete%20System/README_EN.md)

<!-- tags:设计,字典树,字符串,数据流 -->
<!-- tags:设计,字典树,字符串,数据流,排序,堆(优先队列) -->

## 题目描述

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[中文文档](/solution/0600-0699/0642.Design%20Search%20Autocomplete%20System/README.md)

<!-- tags:Design,Trie,String,Data Stream -->
<!-- tags:Design,Trie,String,Data Stream,Sorting,Heap (Priority Queue) -->

## Description

Expand Down
2 changes: 1 addition & 1 deletion solution/0600-0699/0647.Palindromic Substrings/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[English Version](/solution/0600-0699/0647.Palindromic%20Substrings/README_EN.md)

<!-- tags:字符串,动态规划 -->
<!-- tags:双指针,字符串,动态规划 -->

## 题目描述

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[中文文档](/solution/0600-0699/0647.Palindromic%20Substrings/README.md)

<!-- tags:String,Dynamic Programming -->
<!-- tags:Two Pointers,String,Dynamic Programming -->

## Description

Expand Down
2 changes: 1 addition & 1 deletion solution/0900-0999/0924.Minimize Malware Spread/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[English Version](/solution/0900-0999/0924.Minimize%20Malware%20Spread/README_EN.md)

<!-- tags:深度优先搜索,广度优先搜索,并查集,图,哈希表 -->
<!-- tags:深度优先搜索,广度优先搜索,并查集,图,数组,哈希表 -->

## 题目描述

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[中文文档](/solution/0900-0999/0924.Minimize%20Malware%20Spread/README.md)

<!-- tags:Depth-First Search,Breadth-First Search,Union Find,Graph,Hash Table -->
<!-- tags:Depth-First Search,Breadth-First Search,Union Find,Graph,Array,Hash Table -->

## Description

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[English Version](/solution/0900-0999/0928.Minimize%20Malware%20Spread%20II/README_EN.md)

<!-- tags:深度优先搜索,广度优先搜索,并查集,图,哈希表 -->
<!-- tags:深度优先搜索,广度优先搜索,并查集,图,数组,哈希表 -->

## 题目描述

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[中文文档](/solution/0900-0999/0928.Minimize%20Malware%20Spread%20II/README.md)

<!-- tags:Depth-First Search,Breadth-First Search,Union Find,Graph,Hash Table -->
<!-- tags:Depth-First Search,Breadth-First Search,Union Find,Graph,Array,Hash Table -->

## Description

Expand Down
2 changes: 1 addition & 1 deletion solution/1800-1899/1840.Maximum Building Height/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[English Version](/solution/1800-1899/1840.Maximum%20Building%20Height/README_EN.md)

<!-- tags:数组,数学 -->
<!-- tags:数组,数学,排序 -->

## 题目描述

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[中文文档](/solution/1800-1899/1840.Maximum%20Building%20Height/README.md)

<!-- tags:Array,Math -->
<!-- tags:Array,Math,Sorting -->

## Description

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[English Version](/solution/2500-2599/2517.Maximum%20Tastiness%20of%20Candy%20Basket/README_EN.md)

<!-- tags:数组,二分查找,排序 -->
<!-- tags:贪心,数组,二分查找,排序 -->

## 题目描述

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[中文文档](/solution/2500-2599/2517.Maximum%20Tastiness%20of%20Candy%20Basket/README.md)

<!-- tags:Array,Binary Search,Sorting -->
<!-- tags:Greedy,Array,Binary Search,Sorting -->

## Description

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,4 @@ impl Solution {

<!-- tabs:end -->

### 方法二

<!-- tabs:start -->

```python
class Solution:
def findColumnWidth(self, grid: List[List[int]]) -> List[int]:
return [max(len(str(x)) for x in col) for col in zip(*grid)]
```

<!-- tabs:end -->

<!-- end -->
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,4 @@ impl Solution {

<!-- tabs:end -->

### Solution 2

<!-- tabs:start -->

```python
class Solution:
def findColumnWidth(self, grid: List[List[int]]) -> List[int]:
return [max(len(str(x)) for x in col) for col in zip(*grid)]
```

<!-- tabs:end -->

<!-- end -->
14 changes: 7 additions & 7 deletions solution/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
| 0002 | [两数相加](/solution/0000-0099/0002.Add%20Two%20Numbers/README.md) | `递归`,`链表`,`数学` | 中等 | |
| 0003 | [无重复字符的最长子串](/solution/0000-0099/0003.Longest%20Substring%20Without%20Repeating%20Characters/README.md) | `哈希表`,`字符串`,`滑动窗口` | 中等 | |
| 0004 | [寻找两个正序数组的中位数](/solution/0000-0099/0004.Median%20of%20Two%20Sorted%20Arrays/README.md) | `数组`,`二分查找`,`分治` | 困难 | |
| 0005 | [最长回文子串](/solution/0000-0099/0005.Longest%20Palindromic%20Substring/README.md) | `字符串`,`动态规划` | 中等 | |
| 0005 | [最长回文子串](/solution/0000-0099/0005.Longest%20Palindromic%20Substring/README.md) | `双指针`,`字符串`,`动态规划` | 中等 | |
| 0006 | [Z 字形变换](/solution/0000-0099/0006.Zigzag%20Conversion/README.md) | `字符串` | 中等 | |
| 0007 | [整数反转](/solution/0000-0099/0007.Reverse%20Integer/README.md) | `数学` | 中等 | |
| 0008 | [字符串转换整数 (atoi)](/solution/0000-0099/0008.String%20to%20Integer%20%28atoi%29/README.md) | `字符串` | 中等 | |
Expand Down Expand Up @@ -652,12 +652,12 @@
| 0639 | [解码方法 II](/solution/0600-0699/0639.Decode%20Ways%20II/README.md) | `字符串`,`动态规划` | 困难 | |
| 0640 | [求解方程](/solution/0600-0699/0640.Solve%20the%20Equation/README.md) | `数学`,`字符串`,`模拟` | 中等 | |
| 0641 | [设计循环双端队列](/solution/0600-0699/0641.Design%20Circular%20Deque/README.md) | `设计`,`队列`,`数组`,`链表` | 中等 | |
| 0642 | [设计搜索自动补全系统](/solution/0600-0699/0642.Design%20Search%20Autocomplete%20System/README.md) | `设计`,`字典树`,`字符串`,`数据流` | 困难 | 🔒 |
| 0642 | [设计搜索自动补全系统](/solution/0600-0699/0642.Design%20Search%20Autocomplete%20System/README.md) | `设计`,`字典树`,`字符串`,`数据流`,`排序`,`堆(优先队列)` | 困难 | 🔒 |
| 0643 | [子数组最大平均数 I](/solution/0600-0699/0643.Maximum%20Average%20Subarray%20I/README.md) | `数组`,`滑动窗口` | 简单 | |
| 0644 | [子数组最大平均数 II](/solution/0600-0699/0644.Maximum%20Average%20Subarray%20II/README.md) | `数组`,`二分查找`,`前缀和` | 困难 | 🔒 |
| 0645 | [错误的集合](/solution/0600-0699/0645.Set%20Mismatch/README.md) | `位运算`,`数组`,`哈希表`,`排序` | 简单 | |
| 0646 | [最长数对链](/solution/0600-0699/0646.Maximum%20Length%20of%20Pair%20Chain/README.md) | `贪心`,`数组`,`动态规划`,`排序` | 中等 | |
| 0647 | [回文子串](/solution/0600-0699/0647.Palindromic%20Substrings/README.md) | `字符串`,`动态规划` | 中等 | |
| 0647 | [回文子串](/solution/0600-0699/0647.Palindromic%20Substrings/README.md) | `双指针`,`字符串`,`动态规划` | 中等 | |
| 0648 | [单词替换](/solution/0600-0699/0648.Replace%20Words/README.md) | `字典树`,`数组`,`哈希表`,`字符串` | 中等 | |
| 0649 | [Dota2 参议院](/solution/0600-0699/0649.Dota2%20Senate/README.md) | `贪心`,`队列`,`字符串` | 中等 | |
| 0650 | [两个键的键盘](/solution/0600-0699/0650.2%20Keys%20Keyboard/README.md) | `数学`,`动态规划` | 中等 | |
Expand Down Expand Up @@ -934,11 +934,11 @@
| 0921 | [使括号有效的最少添加](/solution/0900-0999/0921.Minimum%20Add%20to%20Make%20Parentheses%20Valid/README.md) | `栈`,`贪心`,`字符串` | 中等 | 第 106 场周赛 |
| 0922 | [按奇偶排序数组 II](/solution/0900-0999/0922.Sort%20Array%20By%20Parity%20II/README.md) | `数组`,`双指针`,`排序` | 简单 | 第 106 场周赛 |
| 0923 | [三数之和的多种可能](/solution/0900-0999/0923.3Sum%20With%20Multiplicity/README.md) | `数组`,`哈希表`,`双指针`,`计数`,`排序` | 中等 | 第 106 场周赛 |
| 0924 | [尽量减少恶意软件的传播](/solution/0900-0999/0924.Minimize%20Malware%20Spread/README.md) | `深度优先搜索`,`广度优先搜索`,`并查集`,`图`,`哈希表` | 困难 | 第 106 场周赛 |
| 0924 | [尽量减少恶意软件的传播](/solution/0900-0999/0924.Minimize%20Malware%20Spread/README.md) | `深度优先搜索`,`广度优先搜索`,`并查集`,`图`,`数组`,`哈希表` | 困难 | 第 106 场周赛 |
| 0925 | [长按键入](/solution/0900-0999/0925.Long%20Pressed%20Name/README.md) | `双指针`,`字符串` | 简单 | 第 107 场周赛 |
| 0926 | [将字符串翻转到单调递增](/solution/0900-0999/0926.Flip%20String%20to%20Monotone%20Increasing/README.md) | `字符串`,`动态规划` | 中等 | 第 107 场周赛 |
| 0927 | [三等分](/solution/0900-0999/0927.Three%20Equal%20Parts/README.md) | `数组`,`数学` | 困难 | 第 107 场周赛 |
| 0928 | [尽量减少恶意软件的传播 II](/solution/0900-0999/0928.Minimize%20Malware%20Spread%20II/README.md) | `深度优先搜索`,`广度优先搜索`,`并查集`,`图`,`哈希表` | 困难 | 第 107 场周赛 |
| 0928 | [尽量减少恶意软件的传播 II](/solution/0900-0999/0928.Minimize%20Malware%20Spread%20II/README.md) | `深度优先搜索`,`广度优先搜索`,`并查集`,`图`,`数组`,`哈希表` | 困难 | 第 107 场周赛 |
| 0929 | [独特的电子邮件地址](/solution/0900-0999/0929.Unique%20Email%20Addresses/README.md) | `数组`,`哈希表`,`字符串` | 简单 | 第 108 场周赛 |
| 0930 | [和相同的二元子数组](/solution/0900-0999/0930.Binary%20Subarrays%20With%20Sum/README.md) | `数组`,`哈希表`,`前缀和`,`滑动窗口` | 中等 | 第 108 场周赛 |
| 0931 | [下降路径最小和](/solution/0900-0999/0931.Minimum%20Falling%20Path%20Sum/README.md) | `数组`,`动态规划`,`矩阵` | 中等 | 第 108 场周赛 |
Expand Down Expand Up @@ -1850,7 +1850,7 @@
| 1837 | [K 进制表示下的各位数字总和](/solution/1800-1899/1837.Sum%20of%20Digits%20in%20Base%20K/README.md) | `数学` | 简单 | 第 238 场周赛 |
| 1838 | [最高频元素的频数](/solution/1800-1899/1838.Frequency%20of%20the%20Most%20Frequent%20Element/README.md) | `贪心`,`数组`,`二分查找`,`前缀和`,`排序`,`滑动窗口` | 中等 | 第 238 场周赛 |
| 1839 | [所有元音按顺序排布的最长子字符串](/solution/1800-1899/1839.Longest%20Substring%20Of%20All%20Vowels%20in%20Order/README.md) | `字符串`,`滑动窗口` | 中等 | 第 238 场周赛 |
| 1840 | [最高建筑高度](/solution/1800-1899/1840.Maximum%20Building%20Height/README.md) | `数组`,`数学` | 困难 | 第 238 场周赛 |
| 1840 | [最高建筑高度](/solution/1800-1899/1840.Maximum%20Building%20Height/README.md) | `数组`,`数学`,`排序` | 困难 | 第 238 场周赛 |
| 1841 | [联赛信息统计](/solution/1800-1899/1841.League%20Statistics/README.md) | `数据库` | 中等 | 🔒 |
| 1842 | [下个由相同数字构成的回文串](/solution/1800-1899/1842.Next%20Palindrome%20Using%20Same%20Digits/README.md) | `双指针`,`字符串` | 困难 | 🔒 |
| 1843 | [可疑银行账户](/solution/1800-1899/1843.Suspicious%20Bank%20Accounts/README.md) | `数据库` | 中等 | 🔒 |
Expand Down Expand Up @@ -2527,7 +2527,7 @@
| 2514 | [统计同位异构字符串数目](/solution/2500-2599/2514.Count%20Anagrams/README.md) | `哈希表`,`数学`,`字符串`,`组合数学`,`计数` | 困难 | 第 94 场双周赛 |
| 2515 | [到目标字符串的最短距离](/solution/2500-2599/2515.Shortest%20Distance%20to%20Target%20String%20in%20a%20Circular%20Array/README.md) | `数组`,`字符串` | 简单 | 第 325 场周赛 |
| 2516 | [每种字符至少取 K 个](/solution/2500-2599/2516.Take%20K%20of%20Each%20Character%20From%20Left%20and%20Right/README.md) | `哈希表`,`字符串`,`滑动窗口` | 中等 | 第 325 场周赛 |
| 2517 | [礼盒的最大甜蜜度](/solution/2500-2599/2517.Maximum%20Tastiness%20of%20Candy%20Basket/README.md) | `数组`,`二分查找`,`排序` | 中等 | 第 325 场周赛 |
| 2517 | [礼盒的最大甜蜜度](/solution/2500-2599/2517.Maximum%20Tastiness%20of%20Candy%20Basket/README.md) | `贪心`,`数组`,`二分查找`,`排序` | 中等 | 第 325 场周赛 |
| 2518 | [好分区的数目](/solution/2500-2599/2518.Number%20of%20Great%20Partitions/README.md) | `数组`,`动态规划` | 困难 | 第 325 场周赛 |
| 2519 | [统计 K-Big 索引的数量](/solution/2500-2599/2519.Count%20the%20Number%20of%20K-Big%20Indices/README.md) | `树状数组`,`线段树`,`数组`,`二分查找`,`分治`,`有序集合`,`归并排序` | 困难 | 🔒 |
| 2520 | [统计能整除数字的位数](/solution/2500-2599/2520.Count%20the%20Digits%20That%20Divide%20a%20Number/README.md) | `数学` | 简单 | 第 326 场周赛 |
Expand Down
Loading