From 097e9c6149e80f095be1b3dbef1c04ff94a7325a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 21:56:50 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- data_structures/binary_tree/lowest_common_ancestor.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/data_structures/binary_tree/lowest_common_ancestor.py b/data_structures/binary_tree/lowest_common_ancestor.py index f34e6f772..33fecb519 100644 --- a/data_structures/binary_tree/lowest_common_ancestor.py +++ b/data_structures/binary_tree/lowest_common_ancestor.py @@ -32,7 +32,7 @@ def create_sparse(max_node: int, parent: list[list[int]]) -> list[list[int]]: For example, consider a small tree where: - Node 1 is the root (its parent is 0), - Nodes 2 and 3 have parent 1. - + We set up the parent table for only two levels (row 0 and row 1) for max_node = 3. (Note that in practice the table has many rows.) @@ -65,7 +65,7 @@ def lowest_common_ancestor( The lists `level` and `parent` must be precomputed. `level[i]` is the depth of node i, and `parent` is a sparse table where parent[0][i] is the direct parent of node i. - + >>> # Consider a simple tree: >>> # 1 >>> # / \\ @@ -142,9 +142,9 @@ def main() -> None: then create the sparse table and compute several lowest common ancestors. The sample tree used is: - + 1 - / | \ + / | \ 2 3 4 / / \\ \\ 5 6 7 8 @@ -160,7 +160,7 @@ def main() -> None: - LCA(8, 8) --> 8 To test main() without it printing to the console, we capture the output. - + >>> import sys >>> from io import StringIO >>> backup = sys.stdout