We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Binary Search Tree : Lowest Common Ancestor
Binary Search Tree : Lowest Common Ancestor
Sort by
recency
|
751 Discussions
|
Please Login in order to post a comment
Simple cpp solution
The actual LCA function is only 9 lines of R, but stdin/stdout/classes aren't pre-populated.
Check out Wear Mart's latest offer while exploring "Binary Search Tree: Lowest Common Ancestor." Dive into the intricacies of this algorithmic problem with our exclusive offer. Discover quality apparel and accessories while tackling programming challenges. Stay stylish and informed as you navigate through solutions and enhance your coding skills. Don't miss out on Wear Mart's offers exceptional offer and elevate your wardrobe while mastering the complexities of binary search trees.
https://wowdeals360.com/abu-dhabi/wear-mart-abu-dhabi/wear-mart-offers/
not optimal but still O(h), I simply brute forced and found both the parents and searched the common one.
let's be honest, are you really able to analyse the three cases and produce the optimal code on the spot? We are software engineers not mathematicians. For me this is like we can memorise and use (phi^n - (1-phi)^n)/sqrt(5) to find fib(n), but we would rather use dynamic programming to bruteforce!
My code is: