This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class TreeNode: | |
| def __init__(self, val, parent=None): | |
| self.val = val | |
| self.left = None | |
| self.right = None | |
| self.parent = parent | |
| self.height = 1 | |
| def update_height(self): | |
| lh = rh = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class TreeNode: | |
| def __init__(self, val): | |
| self.val = val | |
| self.left = None | |
| self.right = None | |
| self.parent = None | |
| class BinarySearchTree: | |
| def __init__(self): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class TrieNode: | |
| def __init__(self, val=""): | |
| self.val = val | |
| self.next = {} | |
| self.eow = False | |
| def all_words(self, prefix): | |
| if self.eow: | |
| yield prefix |