Lowest Common Ancestor of Deepest Leaves | 2 Approaches | Leetcode 1123 | codestorywithMIK
Whatsapp Community Link : https://www.whatsapp.com/channel/0029Va6kVSjICVfiVdsHgi1A
Hi Everyone, this is the 58th video of our Playlist "Binary Tree : Popular Interview Problems".
Now we will be solving an very good Tree problem based on Lowest Common Ancestor - Lowest Common Ancestor of Deepest Leaves | 2 Approaches | Leetcode 1123 | codestorywithMIK
We will solve From 2 Pass solution to 1 Pass Solution
Problem Name : Lowest Common Ancestor of Deepest Leaves | 2 Approaches | Leetcode 1123 | codestorywithMIK
Company Tags :
My solutions on Github(C++ & JAVA) - https://github.com/MAZHARMIK/Interview_DS_Algo/blob/master/Tree/Lowest Common Ancestor of Deepest Leaves.cpp
Leetcode Link : https://leetcode.com/problems/lowest-common-ancestor-of-deepest-leaves
My DP Concepts Playlist : • Roadmap for DP | How to Start DP ? | ...
My Graph Concepts Playlist : • Graph Concepts & Qns - 1 : Graph will...
My Segment Tree Concepts Playlist : • Segment Tree | Introduction | Basics ...
My Recursion Concepts Playlist : • Introduction | Recursion Concepts And...
Trie Playlist - • Word Search II (Google, Amazon, Meta,...
Difference Array Technique: Concepts & Qns : • Introduction | What | How | Differenc...
My GitHub Repo for interview preparation : https://github.com/MAZHARMIK/Interview_DS_Algo
Instagram : https://www.instagram.com/codestorywithmik/
Facebook : https://www.facebook.com/people/codestorywithmik/100090524295846/
Twitter : https://twitter.com/CSwithMIK
Subscribe to my channel : / @codestorywithmik
╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝
Video Summary :
Approach-1 Summary:
This method uses a two-pass strategy. In the first pass, it traverses the tree to record the depth of each node and finds the maximum depth. In the second pass, it uses a Lowest Common Ancestor (LCA) style recursive function to identify the node that is the common ancestor of all nodes at the deepest level. This works by backtracking through the tree and checking where the deepest nodes converge.
Approach-2 Summary:
This approach uses a single recursive pass. At each node, it calculates the depth of its left and right subtrees and also keeps track of the node that is the LCA at that depth. If both sides have equal depth, the current node is the LCA. Otherwise, it returns the deeper subtree’s result. This way, it efficiently finds the LCA of the deepest leaves in one traversal.
✨ Timelines✨
00:00 - Introduction
0:22 - Motivation
0:50 - Problem Explanation
3:25 - Recap LCA
10:32 - Approach-1 - Using LCA
20:17 - Good example Dry Run
26:20 - Coding Approach-1
30:58 - Approach-2 (One Pass)
39:04 - Coding Approach-2
#MIK #mik #Mik
#coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #hindiexplanation #hindiexplained #easyexplaination #interview#interviewtips #interviewpreparation #interview_ds_algo #hinglish #github #design #data #google #video #instagram #facebook #leetcode #computerscience #leetcodesolutions #leetcodequestionandanswers #code #learning #dsalgo #dsa #coding #programming #100daysofcode #developers #techjobs #datastructures #algorithms #webdevelopment #softwareengineering #computerscience #pythoncoding #codinglife #coderlife #javascript #datascience #leetcode #leetcodesolutions #leetcodedailychallenge #codinginterview #interviewprep #technicalinterview #interviewtips #interviewquestions #codingchallenges #interviewready #dsa #hindi #india #hindicoding #hindiprogramming #hindiexplanation #hindidevelopers #hinditech #hindilearning #helpajobseeker #jobseekers #jobsearchtips #careergoals #careerdevelopment #jobhunt #jobinterview #github #designthinking #learningtogether #growthmindset #digitalcontent #techcontent #socialmediagrowth #contentcreation #instagramreels #videomarketing #codestorywithmik #codestorywithmick #codestorywithmikc #codestorywitmik #codestorywthmik #codstorywithmik #codestorywihmik #codestorywithmiik #codeistorywithmik #codestorywithmk #codestorywitmick #codestorymik #codestorwithmik