Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5d8c2f9

Browse files
feat: add solutions to lc problems: No.3319,3322 (doocs#3639)
1 parent 6dfa077 commit 5d8c2f9

File tree

25 files changed

+969
-33
lines changed

25 files changed

+969
-33
lines changed

‎solution/0100-0199/0112.Path Sum/README_EN.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ tags:
3737
<pre>
3838
<strong>Input:</strong> root = [1,2,3], targetSum = 5
3939
<strong>Output:</strong> false
40-
<strong>Explanation:</strong> There two root-to-leaf paths in the tree:
40+
<strong>Explanation:</strong> There are two root-to-leaf paths in the tree:
4141
(1 --&gt; 2): The sum is 3.
4242
(1 --&gt; 3): The sum is 4.
4343
There is no root-to-leaf path with sum = 5.

‎solution/0400-0499/0442.Find All Duplicates in an Array/README_EN.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ tags:
1717

1818
<!-- description:start -->
1919

20-
<p>Given an integer array <code>nums</code> of length <code>n</code> where all the integers of <code>nums</code> are in the range <code>[1, n]</code> and each integer appears <strong>once</strong> or <strong>twice</strong>, return <em>an array of all the integers that appears <strong>twice</strong></em>.</p>
20+
<p>Given an integer array <code>nums</code> of length <code>n</code> where all the integers of <code>nums</code> are in the range <code>[1, n]</code> and each integer appears <strong>at most</strong> <strong>twice</strong>, return <em>an array of all the integers that appears <strong>twice</strong></em>.</p>
2121

2222
<p>You must write an algorithm that runs in <code>O(n)</code> time and uses only <em>constant</em> auxiliary space, excluding the space needed to store the output</p>
2323

‎solution/0800-0899/0887.Super Egg Drop/README.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public:
158158
int superEggDrop(int k, int n) {
159159
int f[n + 1][k + 1];
160160
memset(f, 0, sizeof(f));
161-
function<int(int, int)> dfs = [&](int i, int j) -> int {
161+
auto dfs = [&](auto&& dfs, int i, int j) -> int {
162162
if (i < 1) {
163163
return 0;
164164
}
@@ -171,17 +171,17 @@ public:
171171
int l = 1, r = i;
172172
while (l < r) {
173173
int mid = (l + r + 1) >> 1;
174-
int a = dfs(mid - 1, j - 1);
175-
int b = dfs(i - mid, j);
174+
int a = dfs(dfs, mid - 1, j - 1);
175+
int b = dfs(dfs, i - mid, j);
176176
if (a <= b) {
177177
l = mid;
178178
} else {
179179
r = mid - 1;
180180
}
181181
}
182-
return f[i][j] = max(dfs(l - 1, j - 1), dfs(i - l, j)) + 1;
182+
return f[i][j] = max(dfs(dfs, l - 1, j - 1), dfs(dfs, i - l, j)) + 1;
183183
};
184-
return dfs(n, k);
184+
return dfs(dfs, n, k);
185185
}
186186
};
187187
```

‎solution/0800-0899/0887.Super Egg Drop/README_EN.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public:
141141
int superEggDrop(int k, int n) {
142142
int f[n + 1][k + 1];
143143
memset(f, 0, sizeof(f));
144-
function<int(int, int)> dfs = [&](int i, int j) -> int {
144+
auto dfs = [&](auto&& dfs, int i, int j) -> int {
145145
if (i < 1) {
146146
return 0;
147147
}
@@ -154,17 +154,17 @@ public:
154154
int l = 1, r = i;
155155
while (l < r) {
156156
int mid = (l + r + 1) >> 1;
157-
int a = dfs(mid - 1, j - 1);
158-
int b = dfs(i - mid, j);
157+
int a = dfs(dfs, mid - 1, j - 1);
158+
int b = dfs(dfs, i - mid, j);
159159
if (a <= b) {
160160
l = mid;
161161
} else {
162162
r = mid - 1;
163163
}
164164
}
165-
return f[i][j] = max(dfs(l - 1, j - 1), dfs(i - l, j)) + 1;
165+
return f[i][j] = max(dfs(dfs, l - 1, j - 1), dfs(dfs, i - l, j)) + 1;
166166
};
167-
return dfs(n, k);
167+
return dfs(dfs, n, k);
168168
}
169169
};
170170
```

‎solution/0800-0899/0887.Super Egg Drop/Solution.cpp‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class Solution {
33
int superEggDrop(int k, int n) {
44
int f[n + 1][k + 1];
55
memset(f, 0, sizeof(f));
6-
function<int(int, int)> dfs = [&](int i, int j) -> int {
6+
autodfs = [&](auto&& dfs, int i, int j) -> int {
77
if (i < 1) {
88
return 0;
99
}
@@ -16,16 +16,16 @@ class Solution {
1616
int l = 1, r = i;
1717
while (l < r) {
1818
int mid = (l + r + 1) >> 1;
19-
int a = dfs(mid - 1, j - 1);
20-
int b = dfs(i - mid, j);
19+
int a = dfs(dfs, mid - 1, j - 1);
20+
int b = dfs(dfs, i - mid, j);
2121
if (a <= b) {
2222
l = mid;
2323
} else {
2424
r = mid - 1;
2525
}
2626
}
27-
return f[i][j] = max(dfs(l - 1, j - 1), dfs(i - l, j)) + 1;
27+
return f[i][j] = max(dfs(dfs, l - 1, j - 1), dfs(dfs, i - l, j)) + 1;
2828
};
29-
return dfs(n, k);
29+
return dfs(dfs, n, k);
3030
}
31-
};
31+
};

‎solution/3000-3099/3016.Minimum Number of Pushes to Type Word II/README_EN.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ It can be shown that no other mapping can provide a lower cost.
4949
</pre>
5050

5151
<p><strong class="example">Example 2:</strong></p>
52-
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/3000-3099/3016.Minimum%20Number%20of%20Pushes%20to%20Type%20Word%20II/images/keypadv2e2.png" style="width: 329px; height: 313px;" />
52+
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/3000-3099/3016.Minimum%20Number%20of%20Pushes%20to%20Type%20Word%20II/images/edited.png" style="width: 329px; height: 313px;" />
5353
<pre>
5454
<strong>Input:</strong> word = &quot;xyzxyzxyzxyz&quot;
5555
<strong>Output:</strong> 12

‎solution/3000-3099/3095.Shortest Subarray With OR at Least K I/README_EN.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ tags:
3737
<p><strong>Explanation:</strong></p>
3838

3939
<p>The subarray <code>[3]</code> has <code>OR</code> value of <code>3</code>. Hence, we return <code>1</code>.</p>
40+
41+
<p>Note that <code>[2]</code> is also a special subarray.</p>
4042
</div>
4143

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

‎solution/3300-3399/3314.Construct the Minimum Bitwise Array I/README_EN.md‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3314.Co
2222

2323
<p>If it is <em>not possible</em> to find such a value for <code>ans[i]</code> that satisfies the <strong>condition</strong>, then set <code>ans[i] = -1</code>.</p>
2424

25-
<p>A <strong>prime number</strong> is a natural number greater than 1 with only two factors, 1 and itself.</p>
26-
2725
<p>&nbsp;</p>
2826
<p><strong class="example">Example 1:</strong></p>
2927

‎solution/3300-3399/3315.Construct the Minimum Bitwise Array II/README_EN.md‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3315.Co
2222

2323
<p>If it is <em>not possible</em> to find such a value for <code>ans[i]</code> that satisfies the <strong>condition</strong>, then set <code>ans[i] = -1</code>.</p>
2424

25-
<p>A <strong>prime number</strong> is a natural number greater than 1 with only two factors, 1 and itself.</p>
26-
2725
<p>&nbsp;</p>
2826
<p><strong class="example">Example 1:</strong></p>
2927

‎solution/3300-3399/3316.Find Maximum Removals From Source String/README_EN.md‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3316.Fi
2727

2828
<p>Return the <strong>maximum</strong> number of <em>operations</em> that can be performed.</p>
2929

30-
<p>A <strong>subsequence</strong> is a string that can be derived from another string by deleting some or no characters without changing the order of the remaining characters.</p>
31-
3230
<p>&nbsp;</p>
3331
<p><strong class="example">Example 1:</strong></p>
3432

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /