Sum of Left Leaves | 2 Approaches | META | Leetcode 404 | codestorywithMIK
Whatsapp Community Link : https://www.whatsapp.com/channel/0029Va6kVSjICVfiVdsHgi1A
This is the 32nd Video of our Playlist "Leetcode Easy: Popular Interview Problems".
In this video we will try to solve a good Practice Problem on Binary Tree : Sum of Left Leaves | 2 Approaches | Leetcode 404 | codestorywithMIK
We will solve it using 2 Approaches.
I will explain the intuition so easily that you will never forget and start seeing this as cakewalk EASYYY.
We will do live coding after explanation and see if we are able to pass all the test cases.
Also, please note that my Github solution link below contains both C++ as well as JAVA code.
Problem Name : Sum of Left Leaves | 2 Approaches | Leetcode 404 | codestorywithMIK
Company Tags : META
My solutions on Github(C++ & JAVA) : https://github.com/MAZHARMIK/Interview_DS_Algo/blob/master/Tree/Easy/Sum%20of%20Left%20Leaves.cpp
Leetcode Link : https://leetcode.com/problems/sum-of-left-leaves/
My DP Concepts Playlist : https://youtu.be/7eLMOE1jnls
My Graph Concepts Playlist : https://youtu.be/5JGiZnr6B5w
My Recursion Concepts Playlist : https://www.youtube.com/watch?v=pfb1Zduesi8&list=PLpIkg8OmuX-IBcXsfITH5ql0Lqci1MYPM
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 : https://www.youtube.com/@codestorywithMIK
Summary :
Here's a brief summary of the two approaches:
**Approach 1 (Using Parent Pointer):**
- This approach involves a recursive traversal of the binary tree, passing along a reference to the parent node.
- At each node, it checks if it's a leaf node and if it's a left child of its parent. If both conditions are met, it adds the value of the current node to the sum.
- The recursion continues until all nodes are traversed.
- This approach requires passing the parent node reference, which adds a bit of complexity but allows for identifying left child nodes efficiently.
**Approach 2 (Without Parent Pointer, Only Using a Flag):**
- In this approach, a boolean flag is used to indicate whether the current node is a left child.
- It recursively traverses the tree, maintaining the flag to identify left child nodes.
- When a leaf node is encountered and it's a left child, its value is added to the sum.
- This approach doesn't involve passing the parent node reference, simplifying the implementation compared to the first approach.
- However, it relies solely on the flag to identify left child nodes, which may slightly affect readability.
╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝
✨ Timelines✨
00:00 - Introduction
#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 #newyear2024