Update and rename find_duplicate_subtrees.py to bt_find_duplicate_subtrees.py

This commit is contained in:
marina 2023-08-03 13:16:07 -07:00 committed by GitHub
parent 0871054dd3
commit 57075bd388
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,18 +1,11 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# author: bt3gl # author: bt3gl
#
# Given the root of a binary tree, return all duplicate subtrees. # Given the root of a binary tree, return all duplicate subtrees.
#
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
def find_duplicates(root: Optional[TreeNode]) -> List[Optional[TreeNode]]: def find_duplicates(root: Optional[Node]) -> list[Optional[Node]]:
result = [] result = []
counter = {} counter = {}