[HackerRank][Python3] Binary Search Tree : Lowest Common Ancestor
2018. 7. 20. 22:37 |
프로그래밍/HackerRank
Problem :
https://www.hackerrank.com/challenges/binary-search-tree-lowest-common-ancestor/problem
My Solution :
#!/usr/bin/env python3 def lca(root, v1, v2): if root.info > max(v1, v2): return lca(root.left, v1, v2) if root.info < min(v1, v2): return lca(root.right, v1, v2) return root
'프로그래밍 > HackerRank' 카테고리의 다른 글
[HackerRank][Python3] Time Complexity: Primality (0) | 2018.07.21 |
---|---|
[HackerRank][Python3] Recursion: Davis' Staircase (0) | 2018.07.21 |
[HackerRank][Python3] Recursion: Fibonacci Numbers (0) | 2018.07.20 |
[HackerRank][Python3] Tree: Huffman Decoding (0) | 2018.07.20 |
[HackerRank][Python3] Balanced Brackets (0) | 2018.07.20 |
[HackerRank][Python3] Queues: A Tale of Two Stacks (0) | 2018.07.19 |
[HackerRank][Python3] Abbreviation (0) | 2018.07.18 |
[HackerRank][Python3] Max Array Sum (0) | 2018.07.18 |
최근에 달린 댓글 최근에 달린 댓글