Skip to content

Commit 349b731

Browse files
committed
style: format code and documents
1 parent a175120 commit 349b731

File tree

109 files changed

+369
-292
lines changed

Some content is hidden

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

109 files changed

+369
-292
lines changed

lcci/04.03.List of Depth/Solution.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# self.left = None
66
# self.right = None
77

8+
89
# Definition for singly-linked list.
910
# class ListNode:
1011
# def __init__(self, x):

lcci/17.23.Max Black Square/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ class Solution {
115115
for (int k = n; k > 0; --k) {
116116
for (int i = 0; i <= n - k; ++i) {
117117
for (int j = 0; j <= n - k; ++j) {
118-
if (down[i][j] >= k && right[i][j] >= k && right[i + k - 1][j] >= k && down[i][j + k - 1] >= k) {
118+
if (down[i][j] >= k && right[i][j] >= k && right[i + k - 1][j] >= k
119+
&& down[i][j + k - 1] >= k) {
119120
return new int[] {i, j, k};
120121
}
121122
}

lcci/17.23.Max Black Square/README_EN.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ class Solution {
9393
for (int k = n; k > 0; --k) {
9494
for (int i = 0; i <= n - k; ++i) {
9595
for (int j = 0; j <= n - k; ++j) {
96-
if (down[i][j] >= k && right[i][j] >= k && right[i + k - 1][j] >= k && down[i][j + k - 1] >= k) {
96+
if (down[i][j] >= k && right[i][j] >= k && right[i + k - 1][j] >= k
97+
&& down[i][j + k - 1] >= k) {
9798
return new int[] {i, j, k};
9899
}
99100
}

lcci/17.23.Max Black Square/Solution.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ public int[] findSquare(int[][] matrix) {
1414
for (int k = n; k > 0; --k) {
1515
for (int i = 0; i <= n - k; ++i) {
1616
for (int j = 0; j <= n - k; ++j) {
17-
if (down[i][j] >= k && right[i][j] >= k && right[i + k - 1][j] >= k && down[i][j + k - 1] >= k) {
17+
if (down[i][j] >= k && right[i][j] >= k && right[i + k - 1][j] >= k
18+
&& down[i][j + k - 1] >= k) {
1819
return new int[] {i, j, k};
1920
}
2021
}

lcci/17.23.Max Black Square/Solution.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ def findSquare(self, matrix: List[List[int]]) -> List[int]:
1111
for k in range(n, 0, -1):
1212
for i in range(n - k + 1):
1313
for j in range(n - k + 1):
14-
if down[i][j] >= k and right[i][j] >= k and right[i + k - 1][j] >= k and down[i][j + k - 1] >= k:
14+
if (
15+
down[i][j] >= k
16+
and right[i][j] >= k
17+
and right[i + k - 1][j] >= k
18+
and down[i][j + k - 1] >= k
19+
):
1520
return [i, j, k]
16-
return []
21+
return []

lcof2/剑指 Offer II 029. 排序的循环链表/Solution.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ def insert(self, head: 'Node', insertVal: int) -> 'Node':
2222
and (insertVal <= p.next.val or insertVal >= p.val)
2323
or p.next == head
2424
):
25-
2625
node.next = p.next
2726
p.next = node
2827
break

lcp/LCP 63. 弹珠游戏/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,18 +132,18 @@ class Solution {
132132
List<int[]> ans = new ArrayList<>();
133133
for (int i = 1; i < m - 1; ++i) {
134134
if (plate[i].charAt(0) == '.' && check(i, 0, 0)) {
135-
ans.add(new int[]{i, 0});
135+
ans.add(new int[] {i, 0});
136136
}
137137
if (plate[i].charAt(n - 1) == '.' && check(i, n - 1, 2)) {
138-
ans.add(new int[]{i, n - 1});
138+
ans.add(new int[] {i, n - 1});
139139
}
140140
}
141141
for (int j = 1; j < n - 1; ++j) {
142142
if (plate[0].charAt(j) == '.' && check(0, j, 1)) {
143-
ans.add(new int[]{0, j});
143+
ans.add(new int[] {0, j});
144144
}
145145
if (plate[m - 1].charAt(j) == '.' && check(m - 1, j, 3)) {
146-
ans.add(new int[]{m - 1, j});
146+
ans.add(new int[] {m - 1, j});
147147
}
148148
}
149149
return ans.toArray(new int[0][]);

lcp/LCP 63. 弹珠游戏/Solution.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@ public int[][] ballGame(int num, String[] plate) {
1313
List<int[]> ans = new ArrayList<>();
1414
for (int i = 1; i < m - 1; ++i) {
1515
if (plate[i].charAt(0) == '.' && check(i, 0, 0)) {
16-
ans.add(new int[]{i, 0});
16+
ans.add(new int[] {i, 0});
1717
}
1818
if (plate[i].charAt(n - 1) == '.' && check(i, n - 1, 2)) {
19-
ans.add(new int[]{i, n - 1});
19+
ans.add(new int[] {i, n - 1});
2020
}
2121
}
2222
for (int j = 1; j < n - 1; ++j) {
2323
if (plate[0].charAt(j) == '.' && check(0, j, 1)) {
24-
ans.add(new int[]{0, j});
24+
ans.add(new int[] {0, j});
2525
}
2626
if (plate[m - 1].charAt(j) == '.' && check(m - 1, j, 3)) {
27-
ans.add(new int[]{m - 1, j});
27+
ans.add(new int[] {m - 1, j});
2828
}
2929
}
3030
return ans.toArray(new int[0][]);

run_format.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44
path = os.getcwd()
55

66

7-
def format():
7+
def prettier_format():
8+
"""Format code with prettier"""
89
for suffix in ['md', 'js', 'ts']:
910
command = f'npx prettier --write "**/*.{suffix}"'
1011
os.system(command)
1112

1213

1314
def clang_format():
15+
"""Format code with clang-format"""
1416
suffix = ['c', 'cpp', 'java']
1517
for root, _, files in os.walk(path):
1618
for name in files:
@@ -76,12 +78,13 @@ def format_py():
7678

7779

7880
def git_add():
81+
"""Git add all files"""
7982
command = 'git add .'
8083
os.system(command)
8184

8285

8386
if __name__ == '__main__':
84-
# clang_format()
85-
format()
87+
clang_format()
88+
prettier_format()
8689
# format_py()
8790
# git_add()

solution/0000-0099/0012.Integer to Roman/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ class Solution:
110110
```java
111111
class Solution {
112112
public String intToRoman(int num) {
113-
List<String> cs = List.of("M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I");
113+
List<String> cs
114+
= List.of("M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I");
114115
List<Integer> vs = List.of(1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1);
115116
StringBuilder ans = new StringBuilder();
116117
for (int i = 0, n = cs.size(); i < n; ++i) {

0 commit comments

Comments
 (0)