mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-05 17:34:49 +08:00
Enable ruff RUF100 rule (#11337)
This commit is contained in:
@ -85,7 +85,7 @@ class BinaryTree:
|
||||
"""
|
||||
return self._depth(self.root)
|
||||
|
||||
def _depth(self, node: Node | None) -> int: # noqa: UP007
|
||||
def _depth(self, node: Node | None) -> int:
|
||||
if not node:
|
||||
return 0
|
||||
return 1 + max(self._depth(node.left), self._depth(node.right))
|
||||
|
@ -87,7 +87,7 @@ class SegmentTree(Generic[T]):
|
||||
p = p // 2
|
||||
self.st[p] = self.fn(self.st[p * 2], self.st[p * 2 + 1])
|
||||
|
||||
def query(self, l: int, r: int) -> T | None: # noqa: E741
|
||||
def query(self, l: int, r: int) -> T | None:
|
||||
"""
|
||||
Get range query value in log(N) time
|
||||
:param l: left element index
|
||||
|
@ -152,7 +152,7 @@ class RedBlackTree:
|
||||
self.grandparent.color = 1
|
||||
self.grandparent._insert_repair()
|
||||
|
||||
def remove(self, label: int) -> RedBlackTree: # noqa: PLR0912
|
||||
def remove(self, label: int) -> RedBlackTree:
|
||||
"""Remove label from this tree."""
|
||||
if self.label == label:
|
||||
if self.left and self.right:
|
||||
|
@ -35,7 +35,7 @@ class SegmentTree:
|
||||
"""
|
||||
return idx * 2 + 1
|
||||
|
||||
def build(self, idx, l, r): # noqa: E741
|
||||
def build(self, idx, l, r):
|
||||
if l == r:
|
||||
self.st[idx] = self.A[l]
|
||||
else:
|
||||
@ -56,7 +56,7 @@ class SegmentTree:
|
||||
"""
|
||||
return self.update_recursive(1, 0, self.N - 1, a - 1, b - 1, val)
|
||||
|
||||
def update_recursive(self, idx, l, r, a, b, val): # noqa: E741
|
||||
def update_recursive(self, idx, l, r, a, b, val):
|
||||
"""
|
||||
update(1, 1, N, a, b, v) for update val v to [a,b]
|
||||
"""
|
||||
@ -83,7 +83,7 @@ class SegmentTree:
|
||||
"""
|
||||
return self.query_recursive(1, 0, self.N - 1, a - 1, b - 1)
|
||||
|
||||
def query_recursive(self, idx, l, r, a, b): # noqa: E741
|
||||
def query_recursive(self, idx, l, r, a, b):
|
||||
"""
|
||||
query(1, 1, N, a, b) for query max of [a,b]
|
||||
"""
|
||||
|
@ -66,7 +66,7 @@ class MinHeap:
|
||||
# this is min-heapify method
|
||||
def sift_down(self, idx, array):
|
||||
while True:
|
||||
l = self.get_left_child_idx(idx) # noqa: E741
|
||||
l = self.get_left_child_idx(idx)
|
||||
r = self.get_right_child_idx(idx)
|
||||
|
||||
smallest = idx
|
||||
|
Reference in New Issue
Block a user