Skip to content

Commit c24623a

Browse files
committed
style: format all python code
1 parent 4a1ea8f commit c24623a

File tree

2,416 files changed

+7787
-1276
lines changed

Some content is hidden

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

2,416 files changed

+7787
-1276
lines changed

.prettierignore

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.idea/
2+
.github/
3+
node_modules/
4+
/solution/CONTEST_README.md
5+
/solution/CONTEST_README_EN.md
6+
/solution/summary.md
7+
/solution/summary_en.md
8+
/solution/README.md
9+
/solution/README_EN.md
10+
/solution/readme_template.md
11+
/solution/readme_template_en.md
12+
/solution/problem_readme_template.md
13+
/solution/problem_readme_template_en.md
14+
/solution/bash_problem_readme_template.md
15+
/solution/bash_problem_readme_template_en.md

basic/sorting/InsertionSort/README.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -198,13 +198,16 @@ def insertion_sort(array):
198198
for i in range(len(array)):
199199
cur_index = i
200200
while array[cur_index - 1] > array[cur_index] and cur_index - 1 >= 0:
201-
array[cur_index], array[cur_index - 1] = array[cur_index - 1], array[cur_index]
201+
array[cur_index], array[cur_index - 1] = (
202+
array[cur_index - 1],
203+
array[cur_index],
204+
)
202205
cur_index -= 1
203206
return array
204207

208+
205209
array = [10, 17, 50, 7, 30, 24, 27, 45, 15, 5, 36, 21]
206210
print(insertion_sort(array))
207-
208211
```
209212

210213
<!-- tabs:end -->

basic/sorting/SelectionSort/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -201,17 +201,17 @@ public class Program
201201
```python
202202
def selection_sort(arr):
203203
n = len(arr)
204-
for i in range(n-1):
204+
for i in range(n - 1):
205205
min_index = i
206-
for j in range(i+1, n):
206+
for j in range(i + 1, n):
207207
if arr[j] < arr[min_index]:
208208
min_index = j
209209
arr[min_index], arr[i] = arr[i], arr[min_index]
210210

211+
211212
arr = [26, 11, 99, 33, 69, 77, 55, 56, 67]
212213
selection_sort(arr)
213214
print(arr)
214-
215215
```
216216

217217
<!-- tabs:end -->

lcci/01.01.Is Unique/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class Solution:
4747
pos = ord(c) - ord('a')
4848
if (bitmap & (1 << pos)) != 0:
4949
return False
50-
bitmap |= (1 << pos)
50+
bitmap |= 1 << pos
5151
return True
5252
```
5353

lcci/01.01.Is Unique/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class Solution:
4646
pos = ord(c) - ord('a')
4747
if (bitmap & (1 << pos)) != 0:
4848
return False
49-
bitmap |= (1 << pos)
49+
bitmap |= 1 << pos
5050
return True
5151
```
5252

lcci/01.06.Compress String/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ class Solution:
4949
res = ''
5050
while q < len(S):
5151
if S[p] != S[q]:
52-
res += (S[p] + str(q - p))
52+
res += S[p] + str(q - p)
5353
p = q
5454
q += 1
55-
res += (S[p] + str(q - p))
55+
res += S[p] + str(q - p)
5656
return res if len(res) < len(S) else S
5757
```
5858

lcci/01.06.Compress String/README_EN.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ class Solution:
4949
res = ''
5050
while q < len(S):
5151
if S[p] != S[q]:
52-
res += (S[p] + str(q - p))
52+
res += S[p] + str(q - p)
5353
p = q
5454
q += 1
55-
res += (S[p] + str(q - p))
55+
res += S[p] + str(q - p)
5656
return res if len(res) < len(S) else S
5757
```
5858

lcci/01.07.Rotate Matrix/README.md

-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ class Solution:
7373
matrix[n - j - 1][i] = matrix[n - i - 1][n - j - 1]
7474
matrix[n - i - 1][n - j - 1] = matrix[j][n - i - 1]
7575
matrix[j][n - i - 1] = t
76-
7776
```
7877

7978
### **Java**

lcci/01.07.Rotate Matrix/README_EN.md

-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ class Solution:
9696
matrix[n - j - 1][i] = matrix[n - i - 1][n - j - 1]
9797
matrix[n - i - 1][n - j - 1] = matrix[j][n - i - 1]
9898
matrix[j][n - i - 1] = t
99-
10099
```
101100

102101
### **Java**

lcci/01.08.Zero Matrix/README.md

-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ class Solution:
7878
matrix[i][j] = 0
7979

8080
return matrix
81-
8281
```
8382

8483
### **Java**

lcci/01.08.Zero Matrix/README_EN.md

-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ class Solution:
9797
matrix[i][j] = 0
9898

9999
return matrix
100-
101100
```
102101

103102
### **Java**

lcci/02.01.Remove Duplicate Node/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
# self.val = x
5050
# self.next = None
5151

52+
5253
class Solution:
5354
def removeDuplicateNodes(self, head: ListNode) -> ListNode:
5455
if head is None or head.next is None:

lcci/02.01.Remove Duplicate Node/README_EN.md

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
# self.val = x
5252
# self.next = None
5353

54+
5455
class Solution:
5556
def removeDuplicateNodes(self, head: ListNode) -> ListNode:
5657
if head is None or head.next is None:

lcci/02.02.Kth Node From End of List/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
# self.val = x
4040
# self.next = None
4141

42+
4243
class Solution:
4344
def kthToLast(self, head: ListNode, k: int) -> int:
4445
slow = fast = head

lcci/02.02.Kth Node From End of List/README_EN.md

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
# self.val = x
3434
# self.next = None
3535

36+
3637
class Solution:
3738
def kthToLast(self, head: ListNode, k: int) -> int:
3839
slow = fast = head

lcci/02.03.Delete Middle Node/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
# self.val = x
4848
# self.next = None
4949

50+
5051
class Solution:
5152
def deleteNode(self, node):
5253
"""

lcci/02.03.Delete Middle Node/README_EN.md

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
# self.val = x
3232
# self.next = None
3333

34+
3435
class Solution:
3536
def deleteNode(self, node):
3637
"""

lcci/02.04.Partition List/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
# self.val = x
6868
# self.next = None
6969

70+
7071
class Solution:
7172
def partition(self, head: ListNode, x: int) -> ListNode:
7273
l1, l2 = ListNode(0), ListNode(0)

lcci/02.04.Partition List/README_EN.md

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
# self.val = x
3030
# self.next = None
3131

32+
3233
class Solution:
3334
def partition(self, head: ListNode, x: int) -> ListNode:
3435
l1, l2 = ListNode(0), ListNode(0)

lcci/02.05.Sum Lists/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
# self.val = x
4747
# self.next = None
4848

49+
4950
class Solution:
5051
def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode:
5152
dummy = cur = ListNode(0)

lcci/02.05.Sum Lists/README_EN.md

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
# self.val = x
4444
# self.next = None
4545

46+
4647
class Solution:
4748
def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode:
4849
dummy = cur = ListNode(0)

lcci/02.07.Intersection of Two Linked Lists/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
# self.val = x
3131
# self.next = None
3232

33+
3334
class Solution:
3435
def getIntersectionNode(self, headA: ListNode, headB: ListNode) -> ListNode:
3536
cur1, cur2 = headA, headB

lcci/02.07.Intersection of Two Linked Lists/README_EN.md

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
# self.val = x
5959
# self.next = None
6060

61+
6162
class Solution:
6263
def getIntersectionNode(self, headA: ListNode, headB: ListNode) -> ListNode:
6364
cur1, cur2 = headA, headB

lcci/02.08.Linked List Cycle/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
# self.val = x
3939
# self.next = None
4040

41+
4142
class Solution:
4243
def detectCycle(self, head: ListNode) -> ListNode:
4344
slow = fast = head

lcci/03.01.Three in One/README.md

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

4545
```python
4646
class TripleInOne:
47-
4847
def __init__(self, stackSize: int):
4948
self._capacity = stackSize
5049
self._s = [[], [], []]

lcci/03.01.Three in One/README_EN.md

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

5353
```python
5454
class TripleInOne:
55-
5655
def __init__(self, stackSize: int):
5756
self._capacity = stackSize
5857
self._s = [[], [], []]

lcci/03.02.Min Stack/README.md

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

2222
```python
2323
class MinStack:
24-
2524
def __init__(self):
2625
"""
2726
initialize your data structure here.

lcci/03.02.Min Stack/README_EN.md

-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ minStack.getMin(); --&gt; return -2.</pre>
3434

3535
```python
3636
class MinStack:
37-
3837
def __init__(self):
3938
"""
4039
initialize your data structure here.

lcci/03.03.Stack of Plates/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939

4040
```python
4141

42+
4243
```
4344

4445
### **Java**
@@ -47,6 +48,7 @@
4748

4849
```java
4950

51+
5052
```
5153

5254
### **TypeScript**
@@ -113,6 +115,7 @@ class StackOfPlates {
113115

114116
```
115117
118+
116119
```
117120

118121
<!-- tabs:end -->

lcci/03.03.Stack of Plates/README_EN.md

+16
Original file line numberDiff line numberDiff line change
@@ -12,34 +12,47 @@
1212

1313
<pre>
1414

15+
1516
<strong> Input</strong>:
1617

18+
1719
[&quot;StackOfPlates&quot;, &quot;push&quot;, &quot;push&quot;, &quot;popAt&quot;, &quot;pop&quot;, &quot;pop&quot;]
1820

21+
1922
[[1], [1], [2], [1], [], []]
2023

24+
2125
<strong> Output</strong>:
2226

27+
2328
[null, null, null, 2, 1, -1]
2429

30+
2531
<strong> Explanation</strong>:
2632

33+
2734
</pre>
2835

2936
<p><strong>Example2:</strong></p>
3037

3138
<pre>
3239

40+
3341
<strong> Input</strong>:
3442

43+
3544
[&quot;StackOfPlates&quot;, &quot;push&quot;, &quot;push&quot;, &quot;push&quot;, &quot;popAt&quot;, &quot;popAt&quot;, &quot;popAt&quot;]
3645

46+
3747
[[2], [1], [2], [3], [0], [0], [0]]
3848

49+
3950
<strong> Output</strong>:
4051

52+
4153
[null, null, null, null, 2, 1, 3]
4254

55+
4356
</pre>
4457

4558
## Solutions
@@ -50,12 +63,14 @@
5063

5164
```python
5265

66+
5367
```
5468

5569
### **Java**
5670

5771
```java
5872

73+
5974
```
6075

6176
### **TypeScript**
@@ -122,6 +137,7 @@ class StackOfPlates {
122137

123138
```
124139
140+
125141
```
126142

127143
<!-- tabs:end -->

0 commit comments

Comments
 (0)