Skip to content

Commit a13f89e

Browse files
committed
style: reformat python code using black
* black -S .
1 parent 389e387 commit a13f89e

File tree

486 files changed

+1462
-883
lines changed

Some content is hidden

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

486 files changed

+1462
-883
lines changed

basic/sorting/MergeSort/Main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def merge_sort(nums, left, right):
2323
while j <= right:
2424
tmp.append(nums[j])
2525
j += 1
26-
26+
2727
j = 0
2828
for i in range(left, right + 1):
2929
nums[i] = tmp[j]

lcci/01.01.Is Unique/Solution.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ def isUnique(self, astr: str) -> bool:
55
pos = ord(c) - ord('a')
66
if (bitmap & (1 << pos)) != 0:
77
return False
8-
bitmap |= (1 << pos)
8+
bitmap |= 1 << pos
99
return True

lcci/01.06.Compress String/Solution.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ def compressString(self, S: str) -> str:
66
res = ''
77
while q < len(S):
88
if S[p] != S[q]:
9-
res += (S[p] + str(q - p))
9+
res += S[p] + str(q - p)
1010
p = q
1111
q += 1
12-
res += (S[p] + str(q - p))
13-
return res if len(res) < len(S) else S
12+
res += S[p] + str(q - p)
13+
return res if len(res) < len(S) else S

lcci/01.08.Zero Matrix/Solution.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ def setZeroes(self, matrix: List[List[int]]) -> None:
1010
if matrix[i][j] == 0:
1111
zero_rows.add(i)
1212
zero_cols.add(j)
13-
13+
1414
for i in zero_rows:
1515
for j in range(cols):
1616
matrix[i][j] = 0
17-
17+
1818
for j in zero_cols:
1919
for i in range(rows):
2020
matrix[i][j] = 0
21-
21+
2222
return matrix

lcci/02.01.Remove Duplicate Node/Solution.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# self.val = x
55
# self.next = None
66

7+
78
class Solution:
89
def removeDuplicateNodes(self, head: ListNode) -> ListNode:
910
if head is None or head.next is None:
@@ -18,4 +19,4 @@ def removeDuplicateNodes(self, head: ListNode) -> ListNode:
1819
cache.add(p.val)
1920
p = p.next
2021
cur.next = None
21-
return head
22+
return head

lcci/02.02.Kth Node From End of List/Solution.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# self.val = x
55
# self.next = None
66

7+
78
class Solution:
89
def kthToLast(self, head: ListNode, k: int) -> int:
910
slow = fast = head

lcci/02.03.Delete Middle Node/Solution.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
# self.val = x
55
# self.next = None
66

7+
78
class Solution:
89
def deleteNode(self, node):
910
"""
1011
:type node: ListNode
1112
:rtype: void Do not return anything, modify node in-place instead.
1213
"""
1314
node.val = node.next.val
14-
node.next = node.next.next
15+
node.next = node.next.next

lcci/02.04.Partition List/Solution.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# self.val = x
55
# self.next = None
66

7+
78
class Solution:
89
def partition(self, head: ListNode, x: int) -> ListNode:
910
l1, l2 = ListNode(0), ListNode(0)

lcci/02.05.Sum Lists/Solution.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# self.val = x
55
# self.next = None
66

7+
78
class Solution:
89
def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode:
910
carry = 0
@@ -16,4 +17,4 @@ def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode:
1617
cur = cur.next
1718
l1 = None if not l1 else l1.next
1819
l2 = None if not l2 else l2.next
19-
return dummy.next
20+
return dummy.next

lcci/02.06.Palindrome Linked List/Solution.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ def isPalindrome(self, head: ListNode) -> bool:
1919
if pre.val != head.val:
2020
return False
2121
pre, head = pre.next, head.next
22-
return True
22+
return True

0 commit comments

Comments
 (0)