Skip to content

Commit 2ea76d7

Browse files
authored
feat: update lc problems (#2737)
1 parent 4507b47 commit 2ea76d7

File tree

49 files changed

+429
-214
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+429
-214
lines changed

lcci/16.04.Tic-Tac-Toe/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ function tictactoe(board: string[]): string {
230230
return hasEmptyGrid ? 'Pending' : 'Draw';
231231
}
232232
```
233+
233234
```swift
234235
class Solution {
235236
func tictactoe(_ board: [String]) -> String {
@@ -238,7 +239,7 @@ class Solution {
238239
var cols = Array(repeating: 0, count: n)
239240
var diagonal = 0, antiDiagonal = 0
240241
var hasEmptyGrid = false
241-
242+
242243
for i in 0..<n {
243244
for j in 0..<n {
244245
let c = Array(board[i])[j]
@@ -260,7 +261,7 @@ class Solution {
260261
}
261262
}
262263
}
263-
264+
264265
return hasEmptyGrid ? "Pending" : "Draw"
265266
}
266267
}

lcci/16.04.Tic-Tac-Toe/README_EN.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ class Solution {
251251
var cols = Array(repeating: 0, count: n)
252252
var diagonal = 0, antiDiagonal = 0
253253
var hasEmptyGrid = false
254-
254+
255255
for i in 0..<n {
256256
for j in 0..<n {
257257
let c = Array(board[i])[j]
@@ -273,7 +273,7 @@ class Solution {
273273
}
274274
}
275275
}
276-
276+
277277
return hasEmptyGrid ? "Pending" : "Draw"
278278
}
279279
}

lcci/16.06.Smallest Difference/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ class Solution {
146146
func smallestDifference(_ a: [Int], _ b: [Int]) -> Int {
147147
let sortedB = b.sorted()
148148
var ans = Int.max
149-
149+
150150
for x in a {
151151
let j = search(sortedB, x)
152152
if j < sortedB.count {
@@ -156,10 +156,10 @@ class Solution {
156156
ans = min(ans, abs(x - sortedB[j - 1]))
157157
}
158158
}
159-
159+
160160
return ans
161161
}
162-
162+
163163
private func search(_ nums: [Int], _ x: Int) -> Int {
164164
var l = 0
165165
var r = nums.count

lcci/16.06.Smallest Difference/README_EN.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ class Solution {
152152
func smallestDifference(_ a: [Int], _ b: [Int]) -> Int {
153153
let sortedB = b.sorted()
154154
var ans = Int.max
155-
155+
156156
for x in a {
157157
let j = search(sortedB, x)
158158
if j < sortedB.count {
@@ -162,10 +162,10 @@ class Solution {
162162
ans = min(ans, abs(x - sortedB[j - 1]))
163163
}
164164
}
165-
165+
166166
return ans
167167
}
168-
168+
169169
private func search(_ nums: [Int], _ x: Int) -> Int {
170170
var l = 0
171171
var r = nums.count

solution/0000-0099/0008.String to Integer (atoi)/README_EN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<li><strong>Whitespace</strong>: Ignore any leading whitespace (<code>&quot; &quot;</code>).</li>
1515
<li><strong>Signedness</strong>: Determine the sign by checking if the next character is <code>&#39;-&#39;</code> or <code>&#39;+&#39;</code>, assuming positivity is neither present.</li>
1616
<li><strong>Conversion</strong>: Read the integer by skipping leading zeros&nbsp;until a non-digit character is encountered or the end of the string is reached. If no digits were read, then the result is 0.</li>
17-
<li><strong>Edge case</strong>: If the integer is out of the 32-bit signed integer range <code>[-2<sup>31</sup>, 2<sup>31</sup> - 1]</code>, then round the integer to remain in the range. Specifically, integers less than <code>-2<sup>31</sup></code> should be rounded to <code>-2<sup>31</sup></code>, and integers greater than <code>2<sup>31</sup> - 1</code> should be rounded to <code>2<sup>31</sup> - 1</code>.</li>
17+
<li><strong>Rounding</strong>: If the integer is out of the 32-bit signed integer range <code>[-2<sup>31</sup>, 2<sup>31</sup> - 1]</code>, then round the integer to remain in the range. Specifically, integers less than <code>-2<sup>31</sup></code> should be rounded to <code>-2<sup>31</sup></code>, and integers greater than <code>2<sup>31</sup> - 1</code> should be rounded to <code>2<sup>31</sup> - 1</code>.</li>
1818
</ol>
1919

2020
<p>Return the integer as the final result.</p>

solution/0300-0399/0305.Number of Islands II/README.md

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

33
[English Version](/solution/0300-0399/0305.Number%20of%20Islands%20II/README_EN.md)
44

5-
<!-- tags:并查集,数组 -->
5+
<!-- tags:并查集,数组,哈希表 -->
66

77
## 题目描述
88

solution/0300-0399/0305.Number of Islands II/README_EN.md

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

33
[中文文档](/solution/0300-0399/0305.Number%20of%20Islands%20II/README.md)
44

5-
<!-- tags:Union Find,Array -->
5+
<!-- tags:Union Find,Array,Hash Table -->
66

77
## Description
88

solution/0300-0399/0314.Binary Tree Vertical Order Traversal/README.md

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

33
[English Version](/solution/0300-0399/0314.Binary%20Tree%20Vertical%20Order%20Traversal/README_EN.md)
44

5-
<!-- tags:树,深度优先搜索,广度优先搜索,哈希表,二叉树 -->
5+
<!-- tags:树,深度优先搜索,广度优先搜索,哈希表,二叉树,排序 -->
66

77
## 题目描述
88

solution/0300-0399/0314.Binary Tree Vertical Order Traversal/README_EN.md

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

33
[中文文档](/solution/0300-0399/0314.Binary%20Tree%20Vertical%20Order%20Traversal/README.md)
44

5-
<!-- tags:Tree,Depth-First Search,Breadth-First Search,Hash Table,Binary Tree -->
5+
<!-- tags:Tree,Depth-First Search,Breadth-First Search,Hash Table,Binary Tree,Sorting -->
66

77
## Description
88

solution/0700-0799/0745.Prefix and Suffix Search/README.md

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

33
[English Version](/solution/0700-0799/0745.Prefix%20and%20Suffix%20Search/README_EN.md)
44

5-
<!-- tags:设计,字典树,哈希表,字符串 -->
5+
<!-- tags:设计,字典树,数组,哈希表,字符串 -->
66

77
## 题目描述
88

0 commit comments

Comments
 (0)