Skip to content

Commit e127845

Browse files
committed
feat: update lc problems
1 parent 4f59100 commit e127845

File tree

35 files changed

+536
-96
lines changed

35 files changed

+536
-96
lines changed

lcci/01.02.Check Permutation/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ func CheckPermutation(s1 string, s2 string) bool {
168168
* @param {string} s2
169169
* @return {boolean}
170170
*/
171-
var CheckPermutation = function(s1, s2) {
171+
var CheckPermutation = function (s1, s2) {
172172
if (s1.length != s2.length) {
173173
return false;
174174
}

lcci/01.02.Check Permutation/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ func CheckPermutation(s1 string, s2 string) bool {
148148
* @param {string} s2
149149
* @return {boolean}
150150
*/
151-
var CheckPermutation = function(s1, s2) {
151+
var CheckPermutation = function (s1, s2) {
152152
if (s1.length != s2.length) {
153153
return false;
154154
}

lcci/03.02.Min Stack/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -301,21 +301,21 @@ public class MinStack {
301301
public MinStack() {
302302
stk2.Push(int.MaxValue);
303303
}
304-
304+
305305
public void Push(int x) {
306306
stk1.Push(x);
307307
stk2.Push(Math.Min(x, GetMin()));
308308
}
309-
309+
310310
public void Pop() {
311311
stk1.Pop();
312312
stk2.Pop();
313313
}
314-
314+
315315
public int Top() {
316316
return stk1.Peek();
317317
}
318-
318+
319319
public int GetMin() {
320320
return stk2.Peek();
321321
}

lcci/03.02.Min Stack/README_EN.md

+8-9
Original file line numberDiff line numberDiff line change
@@ -73,21 +73,21 @@ class MinStack {
7373
public MinStack() {
7474
stk2.push(Integer.MAX_VALUE);
7575
}
76-
76+
7777
public void push(int x) {
7878
stk1.push(x);
7979
stk2.push(Math.min(x, stk2.peek()));
8080
}
81-
81+
8282
public void pop() {
8383
stk1.pop();
8484
stk2.pop();
8585
}
86-
86+
8787
public int top() {
8888
return stk1.peek();
8989
}
90-
90+
9191
public int getMin() {
9292
return stk2.peek();
9393
}
@@ -194,7 +194,6 @@ func min(a, b int) int {
194194
*/
195195
```
196196

197-
198197
### **TypeScript**
199198

200199
```ts
@@ -301,21 +300,21 @@ public class MinStack {
301300
public MinStack() {
302301
stk2.Push(int.MaxValue);
303302
}
304-
303+
305304
public void Push(int x) {
306305
stk1.Push(x);
307306
stk2.Push(Math.Min(x, GetMin()));
308307
}
309-
308+
310309
public void Pop() {
311310
stk1.Pop();
312311
stk2.Pop();
313312
}
314-
313+
315314
public int Top() {
316315
return stk1.Peek();
317316
}
318-
317+
319318
public int GetMin() {
320319
return stk2.Peek();
321320
}

lcci/04.02.Minimum Height Tree/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class Solution:
5151
return None
5252
mid = (l + r) >> 1
5353
return TreeNode(nums[mid], dfs(l, mid - 1), dfs(mid + 1, r))
54-
54+
5555
return dfs(0, len(nums) - 1)
5656
```
5757

lcci/17.20.Continuous Median/README_EN.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,15 @@ class MedianFinder {
8282
public MedianFinder() {
8383

8484
}
85-
85+
8686
public void addNum(int num) {
8787
q1.offer(num);
8888
q2.offer(q1.poll());
8989
if (q2.size() - q1.size() > 1) {
9090
q1.offer(q2.poll());
9191
}
9292
}
93-
93+
9494
public double findMedian() {
9595
if (q2.size() > q1.size()) {
9696
return q2.peek();
@@ -116,7 +116,7 @@ public:
116116
MedianFinder() {
117117

118118
}
119-
119+
120120
void addNum(int num) {
121121
q1.push(num);
122122
q2.push(q1.top());
@@ -126,7 +126,7 @@ public:
126126
q2.pop();
127127
}
128128
}
129-
129+
130130
double findMedian() {
131131
if (q2.size() > q1.size()) {
132132
return q2.top();

solution/0000-0099/0016.3Sum Closest/README_EN.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,20 @@
1111
<p>You may assume that each input would have exactly one solution.</p>
1212

1313
<p>&nbsp;</p>
14-
<p><strong>Example 1:</strong></p>
14+
<p><strong class="example">Example 1:</strong></p>
1515

1616
<pre>
1717
<strong>Input:</strong> nums = [-1,2,1,-4], target = 1
1818
<strong>Output:</strong> 2
1919
<strong>Explanation:</strong> The sum that is closest to the target is 2. (-1 + 2 + 1 = 2).
2020
</pre>
2121

22-
<p><strong>Example 2:</strong></p>
22+
<p><strong class="example">Example 2:</strong></p>
2323

2424
<pre>
2525
<strong>Input:</strong> nums = [0,0,0], target = 1
2626
<strong>Output:</strong> 0
27+
<strong>Explanation:</strong> The sum that is closest to the target is 0. (0 + 0 + 0 = 0).
2728
</pre>
2829

2930
<p>&nbsp;</p>

solution/0000-0099/0045.Jump Game II/README_EN.md

+7-4
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@
44

55
## Description
66

7-
<p>Given an array of non-negative integers <code>nums</code>, you are initially positioned at the first index of the array.</p>
7+
<p>You are given a <strong>0-indexed</strong> array of integers <code>nums</code> of length <code>n</code>. You are initially positioned at <code>nums[0]</code>.</p>
88

9-
<p>Each element in the array represents your maximum jump length at that position.</p>
9+
<p>Each element <code>nums[i]</code> represents the maximum length of a forward jump from index <code>i</code>. In other words, if you are at <code>nums[i]</code>, you can jump to any <code>nums[i + j]</code> where:</p>
1010

11-
<p>Your goal is to reach the last index in the minimum number of jumps.</p>
11+
<ul>
12+
<li><code>1 &lt;= j &lt;= nums[i]</code> and</li>
13+
<li><code>i + j &lt; n</code></li>
14+
</ul>
1215

13-
<p>You can assume that you can always reach the last index.</p>
16+
<p>Return <em>the minimum number of jumps to reach </em><code>nums[n - 1]</code>. The test cases are generated such that you can reach <code>nums[n - 1]</code>.</p>
1417

1518
<p>&nbsp;</p>
1619
<p><strong>Example 1:</strong></p>

solution/0100-0199/0155.Min Stack/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -345,21 +345,21 @@ public class MinStack {
345345
public MinStack() {
346346
stk2.Push(int.MaxValue);
347347
}
348-
348+
349349
public void Push(int x) {
350350
stk1.Push(x);
351351
stk2.Push(Math.Min(x, GetMin()));
352352
}
353-
353+
354354
public void Pop() {
355355
stk1.Pop();
356356
stk2.Pop();
357357
}
358-
358+
359359
public int Top() {
360360
return stk1.Peek();
361361
}
362-
362+
363363
public int GetMin() {
364364
return stk2.Peek();
365365
}

solution/0100-0199/0155.Min Stack/README_EN.md

+8-9
Original file line numberDiff line numberDiff line change
@@ -96,21 +96,21 @@ class MinStack {
9696
public MinStack() {
9797
stk2.push(Integer.MAX_VALUE);
9898
}
99-
99+
100100
public void push(int x) {
101101
stk1.push(x);
102102
stk2.push(Math.min(x, stk2.peek()));
103103
}
104-
104+
105105
public void pop() {
106106
stk1.pop();
107107
stk2.pop();
108108
}
109-
109+
110110
public int top() {
111111
return stk1.peek();
112112
}
113-
113+
114114
public int getMin() {
115115
return stk2.peek();
116116
}
@@ -217,7 +217,6 @@ func min(a, b int) int {
217217
*/
218218
```
219219

220-
221220
### **TypeScript**
222221

223222
```ts
@@ -324,21 +323,21 @@ public class MinStack {
324323
public MinStack() {
325324
stk2.Push(int.MaxValue);
326325
}
327-
326+
328327
public void Push(int x) {
329328
stk1.Push(x);
330329
stk2.Push(Math.Min(x, GetMin()));
331330
}
332-
331+
333332
public void Pop() {
334333
stk1.Pop();
335334
stk2.Pop();
336335
}
337-
336+
338337
public int Top() {
339338
return stk1.Peek();
340339
}
341-
340+
342341
public int GetMin() {
343342
return stk2.Peek();
344343
}

solution/0200-0299/0295.Find Median from Data Stream/README_EN.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,15 @@ class MedianFinder {
100100
public MedianFinder() {
101101

102102
}
103-
103+
104104
public void addNum(int num) {
105105
q1.offer(num);
106106
q2.offer(q1.poll());
107107
if (q2.size() - q1.size() > 1) {
108108
q1.offer(q2.poll());
109109
}
110110
}
111-
111+
112112
public double findMedian() {
113113
if (q2.size() > q1.size()) {
114114
return q2.peek();
@@ -134,7 +134,7 @@ public:
134134
MedianFinder() {
135135

136136
}
137-
137+
138138
void addNum(int num) {
139139
q1.push(num);
140140
q2.push(q1.top());
@@ -144,7 +144,7 @@ public:
144144
q2.pop();
145145
}
146146
}
147-
147+
148148
double findMedian() {
149149
if (q2.size() > q1.size()) {
150150
return q2.top();

solution/0300-0399/0341.Flatten Nested List Iterator/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,11 @@ public:
210210
NestedIterator(vector<NestedInteger> &nestedList) {
211211
dfs(nestedList);
212212
}
213-
213+
214214
int next() {
215215
return vals[cur++];
216216
}
217-
217+
218218
bool hasNext() {
219219
return cur < vals.size();
220220
}

solution/0300-0399/0341.Flatten Nested List Iterator/README_EN.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,11 @@ public:
194194
NestedIterator(vector<NestedInteger> &nestedList) {
195195
dfs(nestedList);
196196
}
197-
197+
198198
int next() {
199199
return vals[cur++];
200200
}
201-
201+
202202
bool hasNext() {
203203
return cur < vals.size();
204204
}

solution/0300-0399/0345.Reverse Vowels of a String/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<p>Given a string <code>s</code>, reverse only all the vowels in the string and return it.</p>
88

9-
<p>The vowels are <code>&#39;a&#39;</code>, <code>&#39;e&#39;</code>, <code>&#39;i&#39;</code>, <code>&#39;o&#39;</code>, and <code>&#39;u&#39;</code>, and they can appear in both cases.</p>
9+
<p>The vowels are <code>&#39;a&#39;</code>, <code>&#39;e&#39;</code>, <code>&#39;i&#39;</code>, <code>&#39;o&#39;</code>, and <code>&#39;u&#39;</code>, and they can appear in both lower and upper cases, more than once.</p>
1010

1111
<p>&nbsp;</p>
1212
<p><strong>Example 1:</strong></p>

solution/0600-0699/0622.Design Circular Queue/README_EN.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
## Description
66

7-
<p>Design your implementation of the circular queue. The circular queue is a linear data structure in which the operations are performed based on FIFO (First In First Out) principle and the last position is connected back to the first position to make a circle. It is also called &quot;Ring Buffer&quot;.</p>
7+
<p>Design your implementation of the circular queue. The circular queue is a linear data structure in which the operations are performed based on FIFO (First In First Out) principle, and the last position is connected back to the first position to make a circle. It is also called &quot;Ring Buffer&quot;.</p>
88

99
<p>One of the benefits of the circular queue is that we can make use of the spaces in front of the queue. In a normal queue, once the queue becomes full, we cannot insert the next element even if there is a space in front of the queue. But using the circular queue, we can use the space to store new values.</p>
1010

11-
<p>Implementation the <code>MyCircularQueue</code> class:</p>
11+
<p>Implement the <code>MyCircularQueue</code> class:</p>
1212

1313
<ul>
1414
<li><code>MyCircularQueue(k)</code> Initializes the object with the size of the queue to be <code>k</code>.</li>

solution/0600-0699/0672.Bulb Switcher II/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<ul>
1414
<li><strong>开关 1 :</strong>反转当前所有灯的状态(即开变为关,关变为开)</li>
15-
<li><strong>开关 2 :</strong>反转编号为偶数的灯的状态(即 <code>2, 4, ...</code>)</li>
15+
<li><strong>开关 2 :</strong>反转编号为偶数的灯的状态(即 <code>0, 2, 4, ...</code>)</li>
1616
<li><strong>开关 3 :</strong>反转编号为奇数的灯的状态(即 <code>1, 3, ...</code>)</li>
1717
<li><strong>开关 4 :</strong>反转编号为 <code>j = 3k + 1</code> 的灯的状态,其中 <code>k = 0, 1, 2, ...</code>(即 <code>1, 4, 7, 10, ...</code>)</li>
1818
</ul>
@@ -52,7 +52,7 @@
5252
<strong>解释:</strong>状态可以是:
5353
- 按压开关 1 ,[关, 关, 关]
5454
- 按压开关 2 ,[关, 开, 关]
55-
- 按压开关 3 ,[开, , 开]
55+
- 按压开关 3 ,[开, , 开]
5656
- 按压开关 4 ,[关, 开, 开]
5757
</pre>
5858

0 commit comments

Comments
 (0)