Skip to content

Commit 17dcb2f

Browse files
committed
feat: add solutions to lc problems: No.2460~2463
* No.2460.Apply Operations to an Array * No.2461.Maximum Sum of Distinct Subarrays With Length K * No.2462.Total Cost to Hire K Workers * No.2463.Minimum Total Distance Traveled
1 parent 886885f commit 17dcb2f

File tree

43 files changed

+2178
-31
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2178
-31
lines changed

solution/0000-0099/0005.Longest Palindromic Substring/README_EN.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class Solution {
105105
class Solution {
106106
private String s;
107107
private int n;
108-
108+
109109
public String longestPalindrome(String s) {
110110
this.s = s;
111111
n = s.length();
@@ -121,7 +121,7 @@ class Solution {
121121
}
122122
return s.substring(start, start + mx);
123123
}
124-
124+
125125
private int f(int l, int r) {
126126
while (l >= 0 && r < n && s.charAt(l) == s.charAt(r)) {
127127
--l;

solution/0100-0199/0158.Read N Characters Given read4 II - Call Multiple Times/README_EN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ class Solution:
132132
```java
133133
/**
134134
* The read4 API is defined in the parent class Reader4.
135-
* int read4(char[] buf4);
135+
* int read4(char[] buf4);
136136
*/
137137

138138
public class Solution extends Reader4 {

solution/0100-0199/0158.Read N Characters Given read4 II - Call Multiple Times/Solution.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# The read4 API is already defined for you.
22
# def read4(buf4: List[str]) -> int:
33

4+
45
class Solution:
56
def __init__(self):
67
self.buf4 = [None] * 4

solution/0200-0299/0254.Factor Combinations/Solution.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ def dfs(n, i):
1010
dfs(n // j, j)
1111
t.pop()
1212
j += 1
13+
1314
t = []
1415
ans = []
1516
dfs(n, 2)

solution/0400-0499/0433.Minimum Genetic Mutation/README_EN.md

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,49 +6,40 @@
66

77
<p>A gene string can be represented by an 8-character long string, with choices from <code>&#39;A&#39;</code>, <code>&#39;C&#39;</code>, <code>&#39;G&#39;</code>, and <code>&#39;T&#39;</code>.</p>
88

9-
<p>Suppose we need to investigate a mutation from a gene string <code>start</code> to a gene string <code>end</code> where one mutation is defined as one single character changed in the gene string.</p>
9+
<p>Suppose we need to investigate a mutation from a gene string <code>startGene</code> to a gene string <code>endGene</code> where one mutation is defined as one single character changed in the gene string.</p>
1010

1111
<ul>
1212
<li>For example, <code>&quot;AACCGGTT&quot; --&gt; &quot;AACCGGTA&quot;</code> is one mutation.</li>
1313
</ul>
1414

1515
<p>There is also a gene bank <code>bank</code> that records all the valid gene mutations. A gene must be in <code>bank</code> to make it a valid gene string.</p>
1616

17-
<p>Given the two gene strings <code>start</code> and <code>end</code> and the gene bank <code>bank</code>, return <em>the minimum number of mutations needed to mutate from </em><code>start</code><em> to </em><code>end</code>. If there is no such a mutation, return <code>-1</code>.</p>
17+
<p>Given the two gene strings <code>startGene</code> and <code>endGene</code> and the gene bank <code>bank</code>, return <em>the minimum number of mutations needed to mutate from </em><code>startGene</code><em> to </em><code>endGene</code>. If there is no such a mutation, return <code>-1</code>.</p>
1818

1919
<p>Note that the starting point is assumed to be valid, so it might not be included in the bank.</p>
2020

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

2424
<pre>
25-
<strong>Input:</strong> start = &quot;AACCGGTT&quot;, end = &quot;AACCGGTA&quot;, bank = [&quot;AACCGGTA&quot;]
25+
<strong>Input:</strong> startGene = &quot;AACCGGTT&quot;, endGene = &quot;AACCGGTA&quot;, bank = [&quot;AACCGGTA&quot;]
2626
<strong>Output:</strong> 1
2727
</pre>
2828

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

3131
<pre>
32-
<strong>Input:</strong> start = &quot;AACCGGTT&quot;, end = &quot;AAACGGTA&quot;, bank = [&quot;AACCGGTA&quot;,&quot;AACCGCTA&quot;,&quot;AAACGGTA&quot;]
32+
<strong>Input:</strong> startGene = &quot;AACCGGTT&quot;, endGene = &quot;AAACGGTA&quot;, bank = [&quot;AACCGGTA&quot;,&quot;AACCGCTA&quot;,&quot;AAACGGTA&quot;]
3333
<strong>Output:</strong> 2
3434
</pre>
3535

36-
<p><strong class="example">Example 3:</strong></p>
37-
38-
<pre>
39-
<strong>Input:</strong> start = &quot;AAAAACCC&quot;, end = &quot;AACCCCCC&quot;, bank = [&quot;AAAACCCC&quot;,&quot;AAACCCCC&quot;,&quot;AACCCCCC&quot;]
40-
<strong>Output:</strong> 3
41-
</pre>
42-
4336
<p>&nbsp;</p>
4437
<p><strong>Constraints:</strong></p>
4538

4639
<ul>
47-
<li><code>start.length == 8</code></li>
48-
<li><code>end.length == 8</code></li>
4940
<li><code>0 &lt;= bank.length &lt;= 10</code></li>
50-
<li><code>bank[i].length == 8</code></li>
51-
<li><code>start</code>, <code>end</code>, and <code>bank[i]</code> consist of only the characters <code>[&#39;A&#39;, &#39;C&#39;, &#39;G&#39;, &#39;T&#39;]</code>.</li>
41+
<li><code>startGene.length == endGene.length == bank[i].length == 8</code></li>
42+
<li><code>startGene</code>, <code>endGene</code>, and <code>bank[i]</code> consist of only the characters <code>[&#39;A&#39;, &#39;C&#39;, &#39;G&#39;, &#39;T&#39;]</code>.</li>
5243
</ul>
5344

5445
## Solutions

solution/0700-0799/0769.Max Chunks To Make Sorted/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
<strong>解释:</strong>
3333
我们可以把它分成两块,例如 [1, 0], [2, 3, 4]。
3434
然而,分成 [1, 0], [2], [3], [4] 可以得到最多的块数。
35+
对每个块单独排序后,结果为 [0, 1], [2], [3], [4]
3536
</pre>
3637

3738
<p>&nbsp;</p>

solution/0700-0799/0779.K-th Symbol in Grammar/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<strong>输出:</strong> 0
3131
<strong>解释:</strong>
3232
第一行: 0
33-
第二行: 0<u>1</u>
33+
第二行: <u>0</u>1
3434
</pre>
3535

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

solution/0900-0999/0921.Minimum Add to Make Parentheses Valid/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<li>它可以被写作&nbsp;<code>(A)</code>,其中&nbsp;<code>A</code>&nbsp;是有效字符串。</li>
1515
</ul>
1616

17-
<p>给定一个括号字符串 <code>s</code> ,移动N次,你就可以在字符串的任何位置插入一个括号。</p>
17+
<p>给定一个括号字符串 <code>s</code> ,在每一次操作中,你都可以在字符串的任何位置插入一个括号</p>
1818

1919
<ul>
2020
<li>例如,如果 <code>s = "()))"</code> ,你可以插入一个开始括号为 <code>"(()))"</code> 或结束括号为 <code>"())))"</code> 。</li>

solution/1300-1399/1367.Linked List in Binary Tree/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# [1367. 二叉树中的列表](https://leetcode.cn/problems/linked-list-in-binary-tree)
1+
# [1367. 二叉树中的链表](https://leetcode.cn/problems/linked-list-in-binary-tree)
22

33
[English Version](/solution/1300-1399/1367.Linked%20List%20in%20Binary%20Tree/README_EN.md)
44

solution/1700-1799/1784.Check if Binary String Has at Most One Segment of Ones/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
<p>如果 <code>s</code> 包含 <strong>零个或一个由连续的 <code>'1'</code> 组成的字段</strong> ,返回 <code>true</code>​​​ 。否则,返回 <code>false</code> 。</p>
1212

13-
<p>如果 <code>s</code>&nbsp;&nbsp;<strong>由连续若干个&nbsp;<code>'1'</code> 组成的字段</strong>&nbsp;数量不超过 <code>1</code>,返回 <code>true</code>​​​ 。否则,返回 <code>false</code> 。</p>
14-
1513
<p>&nbsp;</p>
1614

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

0 commit comments

Comments
 (0)