Skip to content

Commit 78e0f6b

Browse files
authored
feat: add solutions to lc problem: No.3366 (doocs#3812)
1 parent 455338f commit 78e0f6b

File tree

24 files changed

+968
-53
lines changed

24 files changed

+968
-53
lines changed

solution/0100-0199/0199.Binary Tree Right Side View/README.md

+36-19
Original file line numberDiff line numberDiff line change
@@ -21,38 +21,55 @@ tags:
2121

2222
<p>给定一个二叉树的 <strong>根节点</strong> <code>root</code>,想象自己站在它的右侧,按照从顶部到底部的顺序,返回从右侧所能看到的节点值。</p>
2323

24-
<p> </p>
24+
<p>&nbsp;</p>
2525

26-
<p><strong>示例 1:</strong></p>
26+
<p><strong class="example">示例 1</strong></p>
2727

28-
<p><img src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0100-0199/0199.Binary%20Tree%20Right%20Side%20View/images/tree.jpg" style="width: 270px; " /></p>
28+
<div class="example-block">
29+
<p><span class="example-io"><b>输入:</b>root = [1,2,3,null,5,null,4]</span></p>
2930

30-
<pre>
31-
<strong>输入:</strong> [1,2,3,null,5,null,4]
32-
<strong>输出:</strong> [1,3,4]
33-
</pre>
31+
<p><strong>输出:</strong><span class="example-io">[1,3,4]</span></p>
3432

35-
<p><strong>示例 2:</strong></p>
33+
<p><strong>解释:</strong></p>
3634

37-
<pre>
38-
<strong>输入:</strong> [1,null,3]
39-
<strong>输出:</strong> [1,3]
40-
</pre>
35+
<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0100-0199/0199.Binary%20Tree%20Right%20Side%20View/images/tmpd5jn43fs-1.png" style="width: 400px; height: 207px;" /></p>
36+
</div>
4137

42-
<p><strong>示例 3:</strong></p>
38+
<p><strong class="example">示例 2:</strong></p>
4339

44-
<pre>
45-
<strong>输入:</strong> []
46-
<strong>输出:</strong> []
47-
</pre>
40+
<div class="example-block">
41+
<p><span class="example-io"><b>输入:</b>root = [1,2,3,4,null,null,null,5]</span></p>
4842

49-
<p> </p>
43+
<p><span class="example-io"><b>输出:</b>[1,3,4,5]</span></p>
44+
45+
<p><strong>解释:</strong></p>
46+
47+
<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0100-0199/0199.Binary%20Tree%20Right%20Side%20View/images/tmpkpe40xeh-1.png" style="width: 400px; height: 214px;" /></p>
48+
</div>
49+
50+
<p><strong class="example">示例 3:</strong></p>
51+
52+
<div class="example-block">
53+
<p><strong>输入:</strong><span class="example-io">root = [1,null,3]</span></p>
54+
55+
<p><strong>输出:</strong><span class="example-io">[1,3]</span></p>
56+
</div>
57+
58+
<p><strong class="example">示例 4:</strong></p>
59+
60+
<div class="example-block">
61+
<p><span class="example-io"><b>输入:</b>root = []</span></p>
62+
63+
<p><strong>输出:</strong><span class="example-io">[]</span></p>
64+
65+
<p>&nbsp;</p>
66+
</div>
5067

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

5370
<ul>
5471
<li>二叉树的节点个数的范围是 <code>[0,100]</code></li>
55-
<li><meta charset="UTF-8" /><code>-100 <= Node.val <= 100</code> </li>
72+
<li><meta charset="UTF-8" /><code>-100&nbsp;&lt;= Node.val &lt;= 100</code>&nbsp;</li>
5673
</ul>
5774

5875
<!-- description:end -->

solution/0100-0199/0199.Binary Tree Right Side View/README_EN.md

+32-13
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,44 @@ tags:
2323

2424
<p>&nbsp;</p>
2525
<p><strong class="example">Example 1:</strong></p>
26-
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0100-0199/0199.Binary%20Tree%20Right%20Side%20View/images/tree.jpg" style="width: 401px; height: 301px;" />
27-
<pre>
28-
<strong>Input:</strong> root = [1,2,3,null,5,null,4]
29-
<strong>Output:</strong> [1,3,4]
30-
</pre>
26+
27+
<div class="example-block">
28+
<p><strong>Input:</strong> <span class="example-io">root = [1,2,3,null,5,null,4]</span></p>
29+
30+
<p><strong>Output:</strong> <span class="example-io">[1,3,4]</span></p>
31+
32+
<p><strong>Explanation:</strong></p>
33+
34+
<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0100-0199/0199.Binary%20Tree%20Right%20Side%20View/images/tmpd5jn43fs-1.png" style="width: 400px; height: 207px;" /></p>
35+
</div>
3136

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

34-
<pre>
35-
<strong>Input:</strong> root = [1,null,3]
36-
<strong>Output:</strong> [1,3]
37-
</pre>
39+
<div class="example-block">
40+
<p><strong>Input:</strong> <span class="example-io">root = [1,2,3,4,null,null,null,5]</span></p>
41+
42+
<p><strong>Output:</strong> <span class="example-io">[1,3,4,5]</span></p>
43+
44+
<p><strong>Explanation:</strong></p>
45+
46+
<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0100-0199/0199.Binary%20Tree%20Right%20Side%20View/images/tmpkpe40xeh-1.png" style="width: 400px; height: 214px;" /></p>
47+
</div>
3848

3949
<p><strong class="example">Example 3:</strong></p>
4050

41-
<pre>
42-
<strong>Input:</strong> root = []
43-
<strong>Output:</strong> []
44-
</pre>
51+
<div class="example-block">
52+
<p><strong>Input:</strong> <span class="example-io">root = [1,null,3]</span></p>
53+
54+
<p><strong>Output:</strong> <span class="example-io">[1,3]</span></p>
55+
</div>
56+
57+
<p><strong class="example">Example 4:</strong></p>
58+
59+
<div class="example-block">
60+
<p><strong>Input:</strong> <span class="example-io">root = []</span></p>
61+
62+
<p><strong>Output:</strong> <span class="example-io">[]</span></p>
63+
</div>
4564

4665
<p>&nbsp;</p>
4766
<p><strong>Constraints:</strong></p>
Loading
Loading
Binary file not shown.

solution/2500-2599/2502.Design Memory Allocator/README_EN.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ tags:
4242
<ul>
4343
<li><code>Allocator(int n)</code> Initializes an <code>Allocator</code> object with a memory array of size <code>n</code>.</li>
4444
<li><code>int allocate(int size, int mID)</code> Find the <strong>leftmost</strong> block of <code>size</code> <strong>consecutive</strong> free memory units and allocate it with the id <code>mID</code>. Return the block&#39;s first index. If such a block does not exist, return <code>-1</code>.</li>
45-
<li><code>int free(int mID)</code> Free all memory units with the id <code>mID</code>. Return the number of memory units you have freed.</li>
45+
<li><code>int freeMemory(int mID)</code> Free all memory units with the id <code>mID</code>. Return the number of memory units you have freed.</li>
4646
</ul>
4747

4848
<p>&nbsp;</p>
4949
<p><strong class="example">Example 1:</strong></p>
5050

5151
<pre>
5252
<strong>Input</strong>
53-
[&quot;Allocator&quot;, &quot;allocate&quot;, &quot;allocate&quot;, &quot;allocate&quot;, &quot;free&quot;, &quot;allocate&quot;, &quot;allocate&quot;, &quot;allocate&quot;, &quot;free&quot;, &quot;allocate&quot;, &quot;free&quot;]
53+
[&quot;Allocator&quot;, &quot;allocate&quot;, &quot;allocate&quot;, &quot;allocate&quot;, &quot;freeMemory&quot;, &quot;allocate&quot;, &quot;allocate&quot;, &quot;allocate&quot;, &quot;freeMemory&quot;, &quot;allocate&quot;, &quot;freeMemory&quot;]
5454
[[10], [1, 1], [1, 2], [1, 3], [2], [3, 4], [1, 1], [1, 1], [1], [10, 2], [7]]
5555
<strong>Output</strong>
5656
[null, 0, 1, 2, 1, 3, 1, 6, 3, -1, 0]
@@ -60,21 +60,21 @@ Allocator loc = new Allocator(10); // Initialize a memory array of size 10. All
6060
loc.allocate(1, 1); // The leftmost block&#39;s first index is 0. The memory array becomes [<strong>1</strong>,_,_,_,_,_,_,_,_,_]. We return 0.
6161
loc.allocate(1, 2); // The leftmost block&#39;s first index is 1. The memory array becomes [1,<strong>2</strong>,_,_,_,_,_,_,_,_]. We return 1.
6262
loc.allocate(1, 3); // The leftmost block&#39;s first index is 2. The memory array becomes [1,2,<strong>3</strong>,_,_,_,_,_,_,_]. We return 2.
63-
loc.free(2); // Free all memory units with mID 2. The memory array becomes [1,_, 3,_,_,_,_,_,_,_]. We return 1 since there is only 1 unit with mID 2.
63+
loc.freeMemory(2); // Free all memory units with mID 2. The memory array becomes [1,_, 3,_,_,_,_,_,_,_]. We return 1 since there is only 1 unit with mID 2.
6464
loc.allocate(3, 4); // The leftmost block&#39;s first index is 3. The memory array becomes [1,_,3,<strong>4</strong>,<strong>4</strong>,<strong>4</strong>,_,_,_,_]. We return 3.
6565
loc.allocate(1, 1); // The leftmost block&#39;s first index is 1. The memory array becomes [1,<strong>1</strong>,3,4,4,4,_,_,_,_]. We return 1.
6666
loc.allocate(1, 1); // The leftmost block&#39;s first index is 6. The memory array becomes [1,1,3,4,4,4,<strong>1</strong>,_,_,_]. We return 6.
67-
loc.free(1); // Free all memory units with mID 1. The memory array becomes [_,_,3,4,4,4,_,_,_,_]. We return 3 since there are 3 units with mID 1.
67+
loc.freeMemory(1); // Free all memory units with mID 1. The memory array becomes [_,_,3,4,4,4,_,_,_,_]. We return 3 since there are 3 units with mID 1.
6868
loc.allocate(10, 2); // We can not find any free block with 10 consecutive free memory units, so we return -1.
69-
loc.free(7); // Free all memory units with mID 7. The memory array remains the same since there is no memory unit with mID 7. We return 0.
69+
loc.freeMemory(7); // Free all memory units with mID 7. The memory array remains the same since there is no memory unit with mID 7. We return 0.
7070
</pre>
7171

7272
<p>&nbsp;</p>
7373
<p><strong>Constraints:</strong></p>
7474

7575
<ul>
7676
<li><code>1 &lt;= n, size, mID &lt;= 1000</code></li>
77-
<li>At most <code>1000</code> calls will be made to <code>allocate</code> and <code>free</code>.</li>
77+
<li>At most <code>1000</code> calls will be made to <code>allocate</code> and <code>freeMemory</code>.</li>
7878
</ul>
7979

8080
<!-- description:end -->

solution/3300-3399/3362.Zero Array Transformation III/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3362.Ze
66

77
<!-- problem:start -->
88

9-
# [3362. 零数组转化 III](https://leetcode.cn/problems/zero-array-transformation-iii)
9+
# [3362. 零数组变换 III](https://leetcode.cn/problems/zero-array-transformation-iii)
1010

1111
[English Version](/solution/3300-3399/3362.Zero%20Array%20Transformation%20III/README_EN.md)
1212

solution/3300-3399/3363.Find the Maximum Number of Fruits Collected/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3363.Fi
5050
<li>The 3<sup>rd</sup> child (blue) moves on the path <code>(3,0) -&gt; (3,1) -&gt; (3,2) -&gt; (3, 3)</code>.</li>
5151
</ul>
5252

53-
<p>In total they collect <code>1 + 6 + 11 + 1 + 4 + 8 + 12 + 13 + 14 + 15 = 100</code> fruits.</p>
53+
<p>In total they collect <code>1 + 6 + 11 + 16 + 4 + 8 + 12 + 13 + 14 + 15 = 100</code> fruits.</p>
5454
</div>
5555

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

0 commit comments

Comments
 (0)