diff options
| author | mo khan <mo.khan@gmail.com> | 2020-08-23 12:02:37 -0600 |
|---|---|---|
| committer | mo khan <mo.khan@gmail.com> | 2020-08-23 12:02:37 -0600 |
| commit | aa0edd0d0b1ceb9e5986c909d368364c8fbbf976 (patch) | |
| tree | f3d0a166d6f7250c67887c6f28f30cf92221bdc9 | |
| parent | 0dd668fede0ab95f225b3e8ee068f6f908748fd2 (diff) | |
Add problem from 3 days ago
| -rw-r--r-- | 2020/08/20/README.md | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/2020/08/20/README.md b/2020/08/20/README.md new file mode 100644 index 0000000..9bdb6b7 --- /dev/null +++ b/2020/08/20/README.md @@ -0,0 +1,23 @@ +│ Given an integer k and a binary search tree, find the floor (less than +│ or equal to) of k, and the ceiling (larger than or equal to) of k. If +│ either does not exist, then print them as None. +│ Here is the definition of a node for the tree. +│class Node: +│ def __init__(self, value): +│ self.left = None +│ self.right = None +│ self.value = value +│def findCeilingFloor(root_node, k, floor=None, ceil=None): +│ # Fill this in. +│root = Node(8) +│root.left = Node(4) +│root.right = Node(12) +│ +│root.left.left = Node(2) +│root.left.right = Node(6) +│ +│root.right.left = Node(10) +│root.right.right = Node(14) +│print findCeilingFloor(root, 5) +│# (4, 6) + |
