Skip to content

Dipin Krishna

I love to code. If you feel the same, then i have some cool codes for you. They are simple but good to get started.

  • Home
  • Blog
  • Privacy Policy
  • About
  • Contact
  • Home
  • Blog
  • Privacy Policy
  • About
  • Contact

Tag Archives: BST

Home/Posts Tagged: BST
python

Python: Lowest Common Ancestor of a Binary Search Tree

Sep 22, 2018Dipin KrishnaCoding, General, PythonBinary Search Tree, BST, LCA, Lowest Common Ancestor, Python, Python 3

Python 3 code to find the Lowest Common Ancestor of a Binary Search Tree def lowestCommonAncestor(root, p, q): """ :type root: TreeNode :type p: TreeNode :type q: TreeNode :rtype: TreeNode """ if root is None or p is None or q is None: return None   if p.val > q.val: temp = p p =

Read More

Search

Theme by Think Up Themes Ltd. Powered by WordPress.
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.Ok