Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: format python code in markdown files #1040

Merged
merged 2 commits into from
Jun 17, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
style: format python code in markdown files
acbin committed Jun 17, 2023
commit d9a1620f78cdccc7f4e4627e5ceeb498d6929e64
2 changes: 2 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -5,8 +5,10 @@ name = "pypi"

[packages]
requests = "*"
black = "*"

[dev-packages]
black = "*"

[requires]
python_version = "3.10"
171 changes: 165 additions & 6 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions lcci/16.19.Pond Sizes/README.md
Original file line number Diff line number Diff line change
@@ -56,13 +56,15 @@ p[find(a)] = find(b)
p = list(range(n))
size = [1] * n


# 返回x的祖宗节点
def find(x):
if p[x] != x:
# 路径压缩
p[x] = find(p[x])
return p[x]


# 合并a和b所在的两个集合
if find(a) != find(b):
size[find(b)] += size[find(a)]
@@ -76,6 +78,7 @@ if find(a) != find(b):
p = list(range(n))
d = [0] * n


# 返回x的祖宗节点
def find(x):
if p[x] != x:
@@ -84,6 +87,7 @@ def find(x):
p[x] = t
return p[x]


# 合并a和b所在的两个集合
p[find(a)] = find(b)
d[find(a)] = distance
1 change: 1 addition & 0 deletions lcof/面试题06. 从尾到头打印链表/README.md
Original file line number Diff line number Diff line change
@@ -59,6 +59,7 @@ class Solution:
# self.val = x
# self.next = None


class Solution:
def reversePrint(self, head: ListNode) -> List[int]:
if head is None:
1 change: 1 addition & 0 deletions lcof/面试题24. 反转链表/README.md
Original file line number Diff line number Diff line change
@@ -66,6 +66,7 @@ class Solution:
# self.val = x
# self.next = None


class Solution:
def reverseList(self, head: ListNode) -> ListNode:
if head is None or head.next is None:
1 change: 1 addition & 0 deletions lcof/面试题25. 合并两个排序的链表/README.md
Original file line number Diff line number Diff line change
@@ -72,6 +72,7 @@ class Solution:
# self.val = x
# self.next = None


class Solution:
def mergeTwoLists(self, l1: ListNode, l2: ListNode) -> ListNode:
if l1 is None or l2 is None:
1 change: 1 addition & 0 deletions lcof/面试题27. 二叉树的镜像/README.md
Original file line number Diff line number Diff line change
@@ -74,6 +74,7 @@ class Solution:
# self.left = None
# self.right = None


class Solution:
def mirrorTree(self, root: TreeNode) -> TreeNode:
if root is None:
1 change: 1 addition & 0 deletions lcof/面试题51. 数组中的逆序对/README.md
Original file line number Diff line number Diff line change
@@ -94,6 +94,7 @@ class BinaryIndexedTree:
x -= x & -x
return s


class Solution:
def reversePairs(self, nums: List[int]) -> int:
alls = sorted(set(nums))
1 change: 1 addition & 0 deletions lcof/面试题55 - I. 二叉树的深度/README.md
Original file line number Diff line number Diff line change
@@ -62,6 +62,7 @@ class Solution:
# self.left = None
# self.right = None


class Solution:
def maxDepth(self, root: TreeNode) -> int:
def dfs(root):
Original file line number Diff line number Diff line change
@@ -84,8 +84,11 @@ class Solution:
# self.left = None
# self.right = None


class Solution:
def lowestCommonAncestor(self, root: 'TreeNode', p: 'TreeNode', q: 'TreeNode') -> 'TreeNode':
def lowestCommonAncestor(
self, root: 'TreeNode', p: 'TreeNode', q: 'TreeNode'
) -> 'TreeNode':
if root.val < p.val and root.val < q.val:
return self.lowestCommonAncestor(root.right, p, q)
if root.val > p.val and root.val > q.val:
Original file line number Diff line number Diff line change
@@ -128,7 +128,7 @@ class Solution:
if window[ch] == need[ch]:
windowCount -= 1
window[ch] -= 1
return "" if minLen == inf else s[start:start + minLen]
return "" if minLen == inf else s[start : start + minLen]
```

### **Java**
Original file line number Diff line number Diff line change
@@ -82,7 +82,6 @@ class MovingAverage:

```python
class MovingAverage:

def __init__(self, size: int):
self.n = size
self.s = 0
Original file line number Diff line number Diff line change
@@ -132,7 +132,6 @@ class BSTIterator:
# self.left = left
# self.right = right
class BSTIterator:

def __init__(self, root: TreeNode):
self.stack = []
while root:
1 change: 1 addition & 0 deletions lcof2/剑指 Offer II 067. 最大的异或/README.md
Original file line number Diff line number Diff line change
@@ -132,6 +132,7 @@ class Trie:
node = node.children[v]
return res


class Solution:
def findMaximumXOR(self, nums: List[int]) -> int:
trie = Trie()
Loading