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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 8 additions & 9 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 3 additions & 2 deletions
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

Lines changed: 7 additions & 4 deletions
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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 8 additions & 9 deletions
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
}

0 commit comments

Comments
 (0)