Skip to content

Commit 840697a

Browse files
committed
style: format code and documents
1 parent debc8de commit 840697a

File tree

30 files changed

+43
-45
lines changed

30 files changed

+43
-45
lines changed

lcof/面试题09. 用两个栈实现队列/README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -299,11 +299,11 @@ public class CQueue {
299299
stack1 = new Stack<int>();
300300
stack2 = new Stack<int>();
301301
}
302-
302+
303303
public void AppendTail(int value) {
304304
stack1.Push(value);
305305
}
306-
306+
307307
public int DeleteHead() {
308308
if (stack2.Count == 0) {
309309
while (stack1.Count != 0) {
@@ -327,4 +327,5 @@ public class CQueue {
327327
```
328328
329329
```
330+
330331
<!-- tabs:end -->

lcof/面试题11. 旋转数组的最小数字/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -175,4 +175,5 @@ public class Solution {
175175
```
176176
177177
```
178+
178179
<!-- tabs:end -->

lcof/面试题12. 矩阵中的路径/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ public class Solution {
298298
{
299299
if (dfs(board, word, i, j, k)) {
300300
return true;
301-
}
301+
}
302302
}
303303
}
304304
return false;

lcof/面试题19. 正则表达式匹配/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ public class Solution {
237237
for(int j = 1; j < n + 1; j++) {
238238
if (p[j-1] == '*') {
239239
dp[0,j] = dp[0,j-2];
240-
}
240+
}
241241
}
242242
for (int i = 1; i < m + 1; i++) {
243243
for (int j = 1; j < n + 1; j++) {

lcof/面试题26. 树的子结构/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ public class Solution {
289289
return false;
290290
}
291291
return dfs(A, B) || IsSubStructure(A.left, B) || IsSubStructure(A.right, B);
292-
}
292+
}
293293

294294
public bool dfs(TreeNode A, TreeNode B) {
295295
if (B == null) {

lcof/面试题28. 对称的二叉树/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ public class Solution {
290290
if (left == null || right == null || left.val != right.val) {
291291
return false;
292292
}
293-
return dfs(left.left, right.right) && dfs(left.right, right.left);
293+
return dfs(left.left, right.right) && dfs(left.right, right.left);
294294
}
295295
}
296296
```

lcof/面试题29. 顺时针打印矩阵/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public class Solution {
197197
}
198198
for (int i = bottom; i >= top; i--) {
199199
ans.Add(matrix[i][left]);
200-
}
200+
}
201201
left += 1;
202202
if (left > right) {
203203
break;

lcof/面试题30. 包含min函数的栈/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -283,21 +283,21 @@ public class MinStack {
283283
minStack = new Stack<int>();
284284
minStack.Push(int.MaxValue);
285285
}
286-
286+
287287
public void Push(int x) {
288288
stack.Push(x);
289289
minStack.Push(Math.Min(minStack.Peek(), x));
290290
}
291-
291+
292292
public void Pop() {
293293
stack.Pop();
294294
minStack.Pop();
295295
}
296-
296+
297297
public int Top() {
298298
return stack.Peek();
299299
}
300-
300+
301301
public int Min() {
302302
return minStack.Peek();
303303
}

lcof/面试题33. 二叉搜索树的后序遍历序列/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ impl Solution {
225225
```
226226

227227
### **C#**
228+
228229
```cs
229230
public class Solution {
230231
public bool VerifyPostorder(int[] postorder) {

lcof/面试题37. 序列化二叉树/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -323,18 +323,18 @@ public class Codec {
323323
}
324324
return str;
325325
}
326-
326+
327327
public TreeNode rdeserialize(LinkedList<string> dataList) {
328328
if (dataList.First.Value.Equals("None")) {
329329
dataList.RemoveFirst();
330330
return null;
331331
}
332-
332+
333333
TreeNode root = new TreeNode(int.Parse(dataList.First.Value));
334334
dataList.RemoveFirst();
335335
root.left = rdeserialize(dataList);
336336
root.right = rdeserialize(dataList);
337-
337+
338338
return root;
339339
}
340340
}

lcof/面试题41. 数据流中的中位数/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ public class MedianFinder {
321321
}
322322
return left;
323323
}
324-
324+
325325
public void AddNum(int num) {
326326
if (nums.Count == 0) {
327327
nums.Add(num);
@@ -335,7 +335,7 @@ public class MedianFinder {
335335
}
336336
}
337337
}
338-
338+
339339
public double FindMedian() {
340340
if (nums.Count % 2 == 1) {
341341
return (double)nums[nums.Count / 2];

lcof/面试题51. 数组中的逆序对/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ public class Solution {
310310
}
311311
return ans;
312312
}
313-
313+
314314
}
315315
```
316316

lcof/面试题53 - I. 在排序数组中查找数字 I/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ public class Solution {
256256
return i;
257257
}
258258
}
259+
```
259260

260261
### **...**
261262

lcof/面试题54. 二叉搜索树的第k大节点/README.md

-1
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,6 @@ public class Solution {
356356
}
357357
```
358358

359-
360359
### **...**
361360

362361
```

lcof/面试题56 - I. 数组中数字出现的次数/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public class Solution {
121121
}
122122
}
123123
int b = eor ^ a;
124-
124+
125125
return new int[]{a, b};
126126
}
127127
}

lcof/面试题59 - II. 队列的最大值/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -356,22 +356,22 @@ public class MaxQueue {
356356
mvq = new LinkedList<int>();
357357
q = new Queue<int>();
358358
}
359-
359+
360360
public int Max_value() {
361361
if (mvq.Count == 0) {
362362
return -1;
363363
}
364364
return mvq.First.Value;
365365
}
366-
366+
367367
public void Push_back(int value) {
368368
q.Enqueue(value);
369369
while (mvq.Count > 0 && mvq.Last.Value < value) {
370370
mvq.RemoveLast();
371371
}
372372
mvq.AddLast(value);
373373
}
374-
374+
375375
public int Pop_front() {
376376
if (q.Count == 0) {
377377
return -1;

lcof/面试题65. 不用加减乘除做加法/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public class Solution {
142142
a = a ^ b;
143143
b = c;
144144
}
145-
145+
146146
return a;
147147
}
148148
}

lcof2/剑指 Offer II 041. 滑动窗口的平均值/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class MovingAverage {
115115
public MovingAverage(int size) {
116116
arr = new int[size];
117117
}
118-
118+
119119
public double next(int val) {
120120
int idx = cnt % arr.length;
121121
s += val - arr[idx];
@@ -141,7 +141,7 @@ class MovingAverage {
141141
public MovingAverage(int size) {
142142
n = size;
143143
}
144-
144+
145145
public double next(int val) {
146146
if (q.size() == n) {
147147
s -= q.pollFirst();
@@ -167,7 +167,7 @@ public:
167167
MovingAverage(int size) {
168168
arr.resize(size);
169169
}
170-
170+
171171
double next(int val) {
172172
int idx = cnt % arr.size();
173173
s += val - arr[idx];
@@ -195,7 +195,7 @@ public:
195195
MovingAverage(int size) {
196196
n = size;
197197
}
198-
198+
199199
double next(int val) {
200200
if (q.size() == n)
201201
{

lcof2/剑指 Offer II 065. 最短的单词编码/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ class Trie {
311311
public:
312312
vector<Trie*> children;
313313
Trie() : children(26) {}
314-
314+
315315
int insert(string w) {
316316
Trie* node = this;
317317
bool pref = true;

lcof2/剑指 Offer II 067. 最大的异或/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,15 @@ class Solution:
110110
class Trie:
111111
def __init__(self):
112112
self.children = [None] * 2
113-
113+
114114
def insert(self, x):
115115
node = self
116116
for i in range(30, -1, -1):
117117
v = (x >> i) & 1
118118
if node.children[v] is None:
119119
node.children[v] = Trie()
120120
node = node.children[v]
121-
121+
122122
def search(self, x):
123123
node = self
124124
res = 0

lcof2/剑指 Offer II 115. 重建序列/README.md

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

7070
<p>注意:本题与主站 444&nbsp;题相同:<a href="https://leetcode.cn/problems/sequence-reconstruction/">https://leetcode-cn.com/problems/sequence-reconstruction/</a></p>
7171

72-
7372
## 解法
7473

7574
<!-- 这里可写通用的实现逻辑 -->

lcof2/剑指 Offer II 115. 重建序列/Solution.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
class Solution:
2-
def sequenceReconstruction(self, nums: List[int], sequences: List[List[int]]) -> bool:
2+
def sequenceReconstruction(
3+
self, nums: List[int], sequences: List[List[int]]
4+
) -> bool:
35
g = defaultdict(list)
46
indeg = [0] * len(nums)
57
for seq in sequences:

solution/0300-0399/0336.Palindrome Pairs/README.md

-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
<strong>输出:</strong>[[0,1],[1,0]]
3333
</pre>
3434

35-
36-
3735
<p><strong>提示:</strong></p>
3836

3937
<ul>

solution/0400-0499/0444.Sequence Reconstruction/Solution.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
class Solution:
2-
def sequenceReconstruction(self, nums: List[int], sequences: List[List[int]]) -> bool:
2+
def sequenceReconstruction(
3+
self, nums: List[int], sequences: List[List[int]]
4+
) -> bool:
35
g = defaultdict(list)
46
indeg = [0] * len(nums)
57
for seq in sequences:

solution/0500-0599/0554.Brick Wall/README.md

-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
<strong>输出:</strong>3
2929
</pre>
3030

31-
32-
3331
<p><strong>提示:</strong></p>
3432

3533
<ul>

solution/0700-0799/0775.Global and Local Inversions/README.md

-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@
4242
<strong>解释:</strong>有 2 个全局倒置,和 1 个局部倒置。
4343
</pre>
4444

45-
46-
4745
<p><strong>提示:</strong></p>
4846

4947
<ul>

solution/0800-0899/0830.Positions of Large Groups/README.md

-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@
4848
<strong>输出:</strong>[]
4949
</pre>
5050

51-
52-
5351
<p><strong>提示:</strong></p>
5452

5553
<ul>

solution/1800-1899/1858.Longest Word With All Prefixes/README_EN.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ private:
166166
bool isEnd;
167167
public:
168168
Trie() : children(26), isEnd(false) {}
169-
169+
170170
void insert(string word) {
171171
Trie* node = this;
172172
for (char c : word)
@@ -177,7 +177,7 @@ public:
177177
}
178178
node->isEnd = true;
179179
}
180-
180+
181181
bool search(string word) {
182182
Trie* node = this;
183183
for (char c : word)

solution/2100-2199/2195.Append K Integers With Minimal Sum/Solution.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ def minimalKSum(self, nums: List[int], k: int) -> int:
55
nums.sort()
66
ans = 0
77
for a, b in pairwise(nums):
8-
n = min(k, b - a - 1)
8+
n = min(k, b - a - 1)
99
if n <= 0:
1010
continue
1111
k -= n

solution/2200-2299/2269.Find the K-Beauty of a Number/Solution.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ def divisorSubstrings(self, num: int, k: int) -> int:
33
ans = 0
44
s = str(num)
55
for i in range(len(s) - k + 1):
6-
t = int(s[i: i + k])
6+
t = int(s[i : i + k])
77
if t and num % t == 0:
88
ans += 1
99
return ans

0 commit comments

Comments
 (0)