Skip to content

Commit 3041b33

Browse files
authored
feat: add solutions to lc problem: No.2599 (doocs#950)
1 parent 028a87b commit 3041b33

File tree

23 files changed

+516
-57
lines changed

23 files changed

+516
-57
lines changed

solution/0200-0299/0263.Ugly Number/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<pre>
3232
<strong>输入:</strong>n = 14
3333
<strong>输出:</strong>false
34-
<strong>解释:</strong>14 不是丑数,因为它包含了另外一个质因数 7
34+
<strong>解释:</strong>14 不是丑数,因为它包含了另外一个质因数&nbsp;<code>7 </code>
3535
</pre>
3636

3737
<p>&nbsp;</p>

solution/0300-0399/0387.First Unique Character in a String/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ class Solution {
188188
return -1;
189189
}
190190
}
191-
```
191+
```
192192

193193
### **...**
194194

solution/0300-0399/0387.First Unique Character in a String/README_EN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ class Solution {
157157
return -1;
158158
}
159159
}
160-
```
160+
```
161161

162162
### **...**
163163

solution/0600-0699/0605.Can Place Flowers/README_EN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<p>You have a long flowerbed in which some of the plots are planted, and some are not. However, flowers cannot be planted in <strong>adjacent</strong> plots.</p>
88

9-
<p>Given an integer array <code>flowerbed</code> containing <code>0</code>&#39;s and <code>1</code>&#39;s, where <code>0</code> means empty and <code>1</code> means not empty, and an integer <code>n</code>, return <em>if</em> <code>n</code> new flowers can be planted in the <code>flowerbed</code> without violating the no-adjacent-flowers rule.</p>
9+
<p>Given an integer array <code>flowerbed</code> containing <code>0</code>&#39;s and <code>1</code>&#39;s, where <code>0</code> means empty and <code>1</code> means not empty, and an integer <code>n</code>, return <code>true</code>&nbsp;<em>if</em> <code>n</code> <em>new flowers can be planted in the</em> <code>flowerbed</code> <em>without violating the no-adjacent-flowers rule and</em> <code>false</code> <em>otherwise</em>.</p>
1010

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

solution/0600-0699/0665.Non-decreasing Array/README_EN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class Solution {
7777
}
7878
return true;
7979
}
80-
80+
8181
private boolean isSorted(int[] nums) {
8282
for (int i = 0; i < nums.length - 1; ++i) {
8383
if (nums[i] > nums[i + 1]) {

solution/1400-1499/1406.Stone Game III/README_EN.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class Solution {
8383
private int n;
8484
private int[] s;
8585
private Integer[] f;
86-
86+
8787
public String stoneGameIII(int[] stoneValue) {
8888
n = stoneValue.length;
8989
s = new int[n + 1];
@@ -95,7 +95,7 @@ class Solution {
9595
int b = s[n] - a;
9696
return a == b ? "Tie" : a > b ? "Alice" : "Bob";
9797
}
98-
98+
9999
private int dfs(int i) {
100100
if (i >= n) {
101101
return 0;

solution/1600-1699/1630.Arithmetic Subarrays/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@
6363

6464
函数 $check(nums, l, r)$ 的实现逻辑如下:
6565

66-
- 首先,我们计算子数组的长度 $n = r - l + 1$,并将子数组中的元素放入集合 $s$ 中,方便后续的查找;
67-
- 然后,我们获取子数组中的最小值 $a_1$ 和最大值 $a_n$,如果 $a_n - a_1$ 不能被 $n - 1$ 整除,那么子数组不可能形成等差数列,直接返回 $false$;否则,我们计算等差数列的公差 $d = \frac{a_n - a_1}{n - 1}$;
68-
- 接下来从 $a_1$ 开始,依次计算等差数列中第 $i$ 项元素,如果第 $i$ 项元素 $a_1 + (i - 1) \times d$ 不在集合 $s$ 中,那么子数组不可能形成等差数列,直接返回 $false$;否则,当我们遍历完所有的元素,说明子数组可以重新排列形成等差数列,返回 $true$。
66+
- 首先,我们计算子数组的长度 $n = r - l + 1$,并将子数组中的元素放入集合 $s$ 中,方便后续的查找;
67+
- 然后,我们获取子数组中的最小值 $a_1$ 和最大值 $a_n$,如果 $a_n - a_1$ 不能被 $n - 1$ 整除,那么子数组不可能形成等差数列,直接返回 $false$;否则,我们计算等差数列的公差 $d = \frac{a_n - a_1}{n - 1}$;
68+
- 接下来从 $a_1$ 开始,依次计算等差数列中第 $i$ 项元素,如果第 $i$ 项元素 $a_1 + (i - 1) \times d$ 不在集合 $s$ 中,那么子数组不可能形成等差数列,直接返回 $false$;否则,当我们遍历完所有的元素,说明子数组可以重新排列形成等差数列,返回 $true$。
6969

7070
在主函数中,我们遍历所有的查询,对于每个查询 $l[i]$ 和 $r[i]$,我们调用函数 $check(nums, l[i], r[i])$ 判断子数组是否可以重新排列形成等差数列,将结果存入答案数组中。
7171

@@ -86,7 +86,7 @@ class Solution:
8686
a1, an = min(nums[l: l + n]), max(nums[l: l + n])
8787
d, mod = divmod(an - a1, n - 1)
8888
return mod == 0 and all((a1 + (i - 1) * d) in s for i in range(1, n))
89-
89+
9090
return [check(nums, left, right) for left, right in zip(l, r)]
9191
```
9292

solution/1600-1699/1630.Arithmetic Subarrays/README_EN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class Solution:
6868
a1, an = min(nums[l: l + n]), max(nums[l: l + n])
6969
d, mod = divmod(an - a1, n - 1)
7070
return mod == 0 and all((a1 + (i - 1) * d) in s for i in range(1, n))
71-
71+
7272
return [check(nums, left, right) for left, right in zip(l, r)]
7373
```
7474

solution/1600-1699/1638.Count Substrings That Differ by One Character/README.md

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

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

9-
<p>给你两个字符串 <code>s</code> 和 <code>t</code> ,请你找出 <code>s</code> 中的非空子串的数目,这些子串满足替换 <strong>一个不同字符</strong> 以后,是 <code>t</code> 串的子串。换言之,请你找到 <code>s</code> 和 <code>t</code> 串中 <strong>恰好</strong> 只有一个字符不同的子字符串对的数目。</p>
9+
<p>给你两个字符串&nbsp;<code>s</code> 和&nbsp;<code>t</code>&nbsp;,请你找出 <code>s</code>&nbsp;中的非空子串的数目,这些子串满足替换 <strong>一个不同字符</strong>&nbsp;以后,是 <code>t</code>&nbsp;串的子串。换言之,请你找到 <code>s</code>&nbsp;和 <code>t</code>&nbsp;串中 <strong>恰好</strong>&nbsp;只有一个字符不同的子字符串对的数目。</p>
1010

11-
<p>比方说, <code>"<strong>compute</strong>r"</code> 和 <code>"<strong>computa</strong>tion"</code> 加粗部分只有一个字符不同: <code>'e'</code>/<code>'a'</code> ,所以这一对子字符串会给答案加 1 。</p>
11+
<p>比方说,&nbsp;<code>"<u>compute</u>r"</code>&nbsp;and&nbsp;<code>"<u>computa</u>tion"&nbsp;</code>只有一个字符不同:&nbsp;<code>'e'</code>/<code>'a'</code>&nbsp;,所以这一对子字符串会给答案加 1 。</p>
1212

1313
<p>请你返回满足上述条件的不同子字符串对数目。</p>
1414

15-
<p>一个 <strong>子字符串</strong> 是一个字符串中连续的字符。</p>
15+
<p>一个 <strong>子字符串</strong>&nbsp;是一个字符串中连续的字符。</p>
1616

17-
<p> </p>
17+
<p>&nbsp;</p>
1818

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

@@ -57,13 +57,13 @@
5757
<b>输出:</b>10
5858
</pre>
5959

60-
<p> </p>
60+
<p>&nbsp;</p>
6161

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

6464
<ul>
65-
<li><code>1 <= s.length, t.length <= 100</code></li>
66-
<li><code>s</code> 和 <code>t</code> 都只包含小写英文字母。</li>
65+
<li><code>1 &lt;= s.length, t.length &lt;= 100</code></li>
66+
<li><code>s</code> 和&nbsp;<code>t</code>&nbsp;都只包含小写英文字母。</li>
6767
</ul>
6868

6969
## 解法

solution/1700-1799/1760.Minimum Limit of Balls in a Bag/README_EN.md

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

1111
<ul>
1212
<li>Take any bag of balls and divide it into two new bags with a <strong>positive </strong>number of balls.
13+
1314
<ul>
1415
<li>For example, a bag of <code>5</code> balls can become two new bags of <code>1</code> and <code>4</code> balls, or two new bags of <code>2</code> and <code>3</code> balls.</li>
1516
</ul>
1617
</li>
18+
1719
</ul>
1820

1921
<p>Your penalty is the <strong>maximum</strong> number of balls in a bag. You want to <strong>minimize</strong> your penalty after the operations.</p>

0 commit comments

Comments
 (0)