Lowest Common Ancestor in BST Solved

🚀 Day 62 of DSA consistency Today I solved Lowest Common Ancestor in a Binary Search Tree. 🔹 Key Idea: In a Binary Search Tree (BST): Left subtree → values smaller than root Right subtree → values greater than root Using this property: If both nodes are greater than root, move right. If both nodes are smaller than root, move left. Otherwise, the current node is the Lowest Common Ancestor. 💡 This allows us to solve the problem efficiently without storing paths. 🧠 Time Complexity: O(H) (H = height of the tree) 💾 Space Complexity: O(H) due to recursion stack. #DSA #Java #BinarySearchTree #LeetCode #CodingJourney #ProblemSolving #100DaysOfCode

  • text

To view or add a comment, sign in

Explore content categories