Lecture 67: Minimum Time to BURN the Entire Binary Tree || C++ Placement Series

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 พ.ย. 2024
  • In this Video, we are going to solve TREE Important Interview Questions.
    There is a lot to learn, Keep in mind “ Mnn bhot karega k chor yrr apne se nahi hoga ya maza nahi aara, Just ask 1 question “ Why I started ? “
    Visit Crio: www.crio.do/re...
    Discord Server Link: / discord
    Course Flow: whimsical.com/...
    Notes Link: drive.google.c...
    Slides Link: drive.google.c...
    Code Links: github.com/lov...
    Questions Links:
    Min time to BURN tree: practice.geeks...
    Do provide you feedback in the comments, we are going to make it best collectively.
    Connect with me here:
    Instagram: / lovebabbar1
    Twitter: / lovebabbar3
    Telegram Group Link: Love Babbar CODE HELP
    telegram.me/lo...
    My Editor: www.instagram....
    Intro Sequence: We have bought all the required Licenses of the Audio, Video & Animation used.
    #DSABusted #LoveBabbar

ความคิดเห็น • 229

  • @govindsuryavanshi6653
    @govindsuryavanshi6653 ปีที่แล้ว +25

    First I have completed all DSA series and now conclude this is Greatest ever DSA series to exist on youtube or paid courses. Your contribution will be remembered. You're God of DSA for us🙇‍♂ Thanks you.

  • @its_nawed4611
    @its_nawed4611 ปีที่แล้ว +10

    If anyone wondering without adding value to map for all the nodes how can we check whether a node is visited or not here is the explanation :
    If you try to access a key value using indexing operator [], then 2 things can happen :
    1->The map contains this key. So it will return the corresponding key value
    2->The map doesn't contain the key. In this case it will automatically add a key to the map with key value null.

  • @invinishku1542
    @invinishku1542 2 ปีที่แล้ว +11

    i was coding this question by myself and just not stored q.size() before entering into for loop ....int the for loop new elements are getting pushed and whole function was working differently.....but thanks for teaching how to debug code by printing imp things...it took me 40 mins ...but the job was done......keep working hard...cheers..

  • @akshithabharde05
    @akshithabharde05 10 ชั่วโมงที่ผ่านมา +1

    Finally I am finishing my series of Binary trees
    thanks a lot bhaiyaa ji
    i have understood this concept finally
    now i am moving towards BST

  • @verma_jay
    @verma_jay ปีที่แล้ว +39

    Your explanation was this good that I coded the solution myself by just seeing the algorithm🔥

    • @pkyadav6230
      @pkyadav6230 ปีที่แล้ว +7

      Really??

    • @Ash_9202
      @Ash_9202 ปีที่แล้ว

      ​@@pkyadav6230either he is better than us or he could be lying.
      Don't stress yourself if you weren't able to come up with a solution yourself.

  • @harshpandey4190
    @harshpandey4190 ปีที่แล้ว +5

    You should be Appreciated for explaining the toughest sum with such a ease

  • @janvikundnani9203
    @janvikundnani9203 2 ปีที่แล้ว +25

    Absolutely love the way you make these hard problems seem so simple!! Thank you so much for such efforts!!🔥

  • @shashanksingh4708
    @shashanksingh4708 2 ปีที่แล้ว +9

    I was able to write the code myself after watching the first half of the video. Thanks for the awesome content!

  • @yashchauhan7221
    @yashchauhan7221 2 ปีที่แล้ว +21

    A Single thank you comment is not enough for the efforts bhaiya don't worry about views as people are left behind becoz of your consistent nature and Big Thumbs Up 🔥🔥

  • @kumarpawansahh
    @kumarpawansahh 2 ปีที่แล้ว +5

    Sabd kamm parr jaa rhe hai aapki dedication dekh kr ❤️

  • @shubhamrao5952
    @shubhamrao5952 ปีที่แล้ว +2

    This question was asked by me 2 years back in Paytm SDE 1 interview.

  • @anshumansharma1069
    @anshumansharma1069 ปีที่แล้ว +2

    To be honest bhtt aasan laga jaise apne sikhaya bhaiyaa💖💖

  • @AA-wy9vw
    @AA-wy9vw 2 ปีที่แล้ว +3

    Loving the series bhaiya! Aapki consistency hume inspire karti hai aur mehnat marne ke liye

  • @Shyara2308
    @Shyara2308 ปีที่แล้ว

    sir aaj meko 1 and half month ho gya consist hu course kafi accha bana hai i like it . samaz nahi aa rha to me 3-4 bar piche ja kr dekh rha hu but koi boriat nahi ho rahi , love babber ke course ko love dher sara

  • @Nishant-n8e
    @Nishant-n8e 10 หลายเดือนก่อน

    i did with pair function

  • @RohitKumar-lt2bo
    @RohitKumar-lt2bo 7 หลายเดือนก่อน

    TC: O(n) //when unordered_map is used insted of map
    SC: O(n)

  • @mr.himanshu4299
    @mr.himanshu4299 2 ปีที่แล้ว

    thoda piche reh gya hun pr dheere dheere cover kr rha hun end takk complete krunga course ko keep uploading babbar bhai

  • @MohitKumar-ys8jd
    @MohitKumar-ys8jd ปีที่แล้ว +2

    Your explanation is the best!! Thanks for this amazing playlist!!

  • @aqusatabassumsyedsadiqueal5920
    @aqusatabassumsyedsadiqueal5920 2 ปีที่แล้ว +3

    You're continuing despite less views in later vedios , 👏👏👏

  • @ramanjaneyuluv479
    @ramanjaneyuluv479 11 หลายเดือนก่อน +1

    babbar bhayya is love 💝

  • @code_sleep_live
    @code_sleep_live 5 หลายเดือนก่อน

    I think a better solution is solving using recursion after creating mapping with parent and finding target node as done in the video. What we can do is pass cur node and prev node in recursion and recursively check for left right and parent unless any of them is equal to prev node and then take the max time from the generated branches.The code will look like
    class Solution {
    int minBurnTime(Node* cur,Node* prev,map &m)
    {
    if(cur==NULL)
    return 0;
    int time=0;
    if(m[cur]!=prev)
    time=minBurnTime(m[cur],cur,m);
    if(cur->left!=prev)
    time=max(time,minBurnTime(cur->left,cur,m));
    if(cur->right!=prev)
    time=max(time,minBurnTime(cur->right,cur,m));
    return time+1;
    }
    public:
    int minTime(Node* root, int target)
    {
    if(root==NULL)
    return 0;
    map m;
    queue q;
    Node* tar;
    q.push(root);
    m[root]=NULL;
    while(!q.empty())
    {
    Node* t=q.front();
    q.pop();
    if(t->data==target)
    tar=t;
    if(t->left)
    {
    m[t->left]=t;
    q.push(t->left);
    }
    if(t->right)
    {
    m[t->right]=t;
    q.push(t->right);
    }
    }
    return minBurnTime(tar,NULL,m)-1;
    }
    };

  • @RohitKumar-oo8lo
    @RohitKumar-oo8lo 2 ปีที่แล้ว +2

    Dhamaal machaa rha hai Course bhaiya!!!

  • @utkarshsingh1457
    @utkarshsingh1457 2 ปีที่แล้ว +4

    Hard level question bhi easy laga... aur pehli baar me he samajh aagya.. thanks to your explanation and to your dedication to give us such a good content!!!

    • @pranayavnish8028
      @pranayavnish8028 ปีที่แล้ว

      bro easy is liye lga because he taught the brute force soln.
      optimized m dfs lagana h without using any extra space.
      Aise hi h gfg pe HARD ka tag nhi lga hua.

    • @Ash_9202
      @Ash_9202 ปีที่แล้ว

      ​@@pranayavnish8028tbhi itna lamba solution bana hai
      Par kar bhi kya skte hai jb tk graphs pe na poch jaye hum

    • @pranayavnish8028
      @pranayavnish8028 ปีที่แล้ว

      @@Ash_9202 vai graphs kaha se aagya bich m?? Ye video wala soln to 1st year ke students v khud se bna lenge,
      This soln(as the optimal) will surely get u rejected in an interview , check leetcode discussions.

    • @Ash_9202
      @Ash_9202 ปีที่แล้ว

      @@pranayavnish8028 agr koi 1st year student kr skta hai to pkka intelligent hoga bhai.
      Mujhe to aise solution ki Intuition hi nahi aaegi. I guess I'm not that intelligent.

  • @monubhargav346
    @monubhargav346 ปีที่แล้ว

    space complexity is becoming n but allowed space complexity is O(height of tree)

  • @keshavgambhir9894
    @keshavgambhir9894 2 ปีที่แล้ว +2

    Present bhaiya
    Consistency op 🔥🔥🔥🔥
    Commenting for a better reach

  • @prashantshukla6870
    @prashantshukla6870 2 ปีที่แล้ว +10

    I can say today😜 Maine toh aag lga di binary tree ko 😂😂😂😂

  • @KPCoder
    @KPCoder 2 ปีที่แล้ว +2

    Thanks you sir, excellent content, no one can explain like you from basic 🙏 god bless you

  • @dipakkumarsingh.7151
    @dipakkumarsingh.7151 3 หลายเดือนก่อน

    Aaj to aag lagadi bhai. dhuwa dhuwa kardiya binary tree ka

  • @JungleKiKahaniyan8
    @JungleKiKahaniyan8 2 ปีที่แล้ว +2

    Maja aa raha hai
    Aapki consistency ++

  • @letsstartwithrahul8841
    @letsstartwithrahul8841 ปีที่แล้ว +2

    in this code no significance of bool flag because by help of flag we only save last iteration
    and last iteration will be save by only q.size() if no element will push in queue then this is the case when queue is empty

    • @Vishal-cm4dl
      @Vishal-cm4dl ปีที่แล้ว

      Yeah, simply we can increment time every time when !q.empy()

  • @ashurajput3526
    @ashurajput3526 6 หลายเดือนก่อน

    best explanation for burning tree on utube

  • @parikshitgupta7711
    @parikshitgupta7711 2 ปีที่แล้ว +2

    Instead of using vis as a map, you can use a set and check ki agar set mein voh node hai ki nahi, it will save space

    • @ishansingh6241
      @ishansingh6241 10 หลายเดือนก่อน

      I am thinking mai ise adjancy list bana kr bsf chala dun usse bhi ho jayega sayad.

  • @azaankhan5208
    @azaankhan5208 2 ปีที่แล้ว +8

    Superbbbbb !!! Thank you so much for all the efforts.... I have one query, how many more videos will this series going to have.. ?

  • @RohitSingh-hc8yi
    @RohitSingh-hc8yi ปีที่แล้ว +1

    Bhaiya in beginning itself you said it is a hard problem let's see if I'll be understand it or not

  • @trojanhorse8278
    @trojanhorse8278 10 หลายเดือนก่อน

    I think we should simply create a graph from the given tree and thereby the bfs will be bit more easy. That's the way I solved this question.

  • @AmitKumar-fk8mm
    @AmitKumar-fk8mm ปีที่แล้ว +1

    please someone give me the code links
    provided link has links only till lecture 65

  • @vivek25467
    @vivek25467 2 หลายเดือนก่อน

    save trees !! save nature !! save lives 🙃

  • @amishapandey6875
    @amishapandey6875 ปีที่แล้ว

    Thankyou so much Bhaiya. Can't be more thankful !

  • @mriduljain6809
    @mriduljain6809 2 ปีที่แล้ว

    Loving the series bhaiya... Sab samajh aa rha h

  • @vinaygupta2369
    @vinaygupta2369 2 ปีที่แล้ว +1

    Bhaiya, es lacture ka code github pe nahi hai.. please upload kar dijiye.

  • @crazyduniya128
    @crazyduniya128 2 ปีที่แล้ว

    bohot badiya question maja aa gya! wah babbar ji wah

  • @Phantomex984
    @Phantomex984 ปีที่แล้ว +1

    Here is the code with some minor updates :



    class Solution {
    private:
    Node* createParentMapping(Node* root, int target, map& nodeToParent) {
    Node* res = nullptr;
    queue q;
    q.push(root);
    nodeToParent[root] = nullptr;
    while (!q.empty()) {
    Node* front = q.front();
    q.pop();
    if (front->data == target) {
    res = front;
    }
    if (front->left) {
    nodeToParent[front->left] = front;
    q.push(front->left);
    }
    if (front->right) {
    nodeToParent[front->right] = front;
    q.push(front->right);
    }
    }
    return res;
    }
    int burnTree(Node* root, map& nodeToParent) {
    if (!root) {
    return 0;
    }
    unordered_map visited;
    queue q;
    q.push(root);
    visited[root] = true;
    int ans = 0;
    while (!q.empty()) {
    int size = q.size();
    bool flag = false;
    for (int i = 0; i < size; i++) {
    Node* front = q.front();
    q.pop();
    if (front->left && !visited[front->left]) {
    flag = true;
    q.push(front->left);
    visited[front->left] = true;
    }
    if (front->right && !visited[front->right]) {
    flag = true;
    q.push(front->right);
    visited[front->right] = true;
    }
    if (nodeToParent[front] && !visited[nodeToParent[front]]) {
    flag = true;
    q.push(nodeToParent[front]);
    visited[nodeToParent[front]] = true;
    }
    }
    if (flag) {
    ans++;
    }
    }
    return ans;
    }
    public:
    int minTime(Node* root, int target) {
    map nodeToParent;
    Node* targetNode = createParentMapping(root, target, nodeToParent);
    int ans = burnTree(targetNode, nodeToParent);
    return ans;
    }
    };

  • @unboxtheuniverse5336
    @unboxtheuniverse5336 2 ปีที่แล้ว +4

    Congratulations for 125K family 🤩🥳🥳🥳
    Mehnat he aapki 🤍
    🚨🚨🚨🚨
    Bhaiya plz make a Roadmap For InternShip 🥺 with DSA busted Course as resource 🤩

  • @rachit_joshi
    @rachit_joshi 7 หลายเดือนก่อน

    Thank You So Much BHRATA SHREE !!!!!!!

  • @vedantchaudhari8610
    @vedantchaudhari8610 ปีที่แล้ว +1

    iska b code nhi hai bhaiyaa github pe yahase aage ke lecture nhi he plz krdo upload

  • @prashantbirajdar9271
    @prashantbirajdar9271 2 ปีที่แล้ว

    very nice bhaiyaa everything is understood...... bit tricky but after practicing 2 or three times it would be easy to impliment and understand ...thanks bhaiyaa... keep it up!! your dedication is inspiration to all of us...!!!

  • @RahulKumar-wt9qc
    @RahulKumar-wt9qc 2 ปีที่แล้ว +1

    Jabardast bhaiya 👍👍

  • @suyashjain3223
    @suyashjain3223 ปีที่แล้ว

    You made the Hard problem easy, Thanks a lot

  • @jenithpatel5594
    @jenithpatel5594 2 ปีที่แล้ว +1

    Here, you solved using O(N) space complexity, but in question, we require O(H) space complexity.

  • @sachinrathod8319
    @sachinrathod8319 2 ปีที่แล้ว

    Sahi questions tha bhai maja aa gaya solve karne ka.

  • @SirAkPandey
    @SirAkPandey ปีที่แล้ว

    Best solution for this problem 👍🏻♥️🙏

  • @_AKSHATMANGAL
    @_AKSHATMANGAL ปีที่แล้ว

    Very nice bhaiya but for only typing speed dont write the misspelled word again and again, it leads to distraction.

  • @tusharvaish8096
    @tusharvaish8096 2 ปีที่แล้ว

    bhaiya apke is video ne toh dil jeet liya thankyou for this awesome series ;

  • @kamranalam2002
    @kamranalam2002 ปีที่แล้ว

    bhaijaan please yhi c++ ke tarah 1 JAVA ka placement dsa course le aaye WITHOUT ANY ONE SHOT on youtube

  • @tejashmaurya2149
    @tejashmaurya2149 ปีที่แล้ว

    Salute You Bhaiya💯💯💯

  • @anuragpatel7787
    @anuragpatel7787 8 หลายเดือนก่อน

    hnji this is anurag patel
    Lec 67 completed successfully ✅

  • @daipayannit-s415
    @daipayannit-s415 ปีที่แล้ว

    Commenting for better reach!!

  • @RohitSingh-hc8yi
    @RohitSingh-hc8yi ปีที่แล้ว +1

    thanks a lot bhaiya

  • @suranjandhara7535
    @suranjandhara7535 2 ปีที่แล้ว

    Hello Bhaiya ❤️😍😘🥰😘🥰.... Aa gya hu.....
    Ab to college khul chuka hai... Abhi college me hu
    Thanks bhaiya ❤️❤️😍😍😍😍😍😍

  • @prikshit_sharma4071
    @prikshit_sharma4071 2 ปีที่แล้ว

    Bhaiya ham apko nam roshan krege ❤️

  • @ayushp4471
    @ayushp4471 2 ปีที่แล้ว

    Thank you bhaiya for your efforts and also your explanation is the BEST❤

  • @eshuthakur2982
    @eshuthakur2982 10 หลายเดือนก่อน

    Front-left=front how will this create map between two nodes😢

  • @afeefuddin8883
    @afeefuddin8883 ปีที่แล้ว

    Learnt coding, now need to learn the intiution myself
    P.S: Coded on my own.

  • @shashikantverma9931
    @shashikantverma9931 2 ปีที่แล้ว

    Bhai Bhai Bhai consistency oppppoo

  • @SauravKumar-yp1fy
    @SauravKumar-yp1fy 2 ปีที่แล้ว +1

    class Solution {
    public:
    void getAdjacents(Node*root,Node*parent,unordered_map&mp)
    {
    if(!root)
    {
    return;
    }
    vectortemp;
    if(parent!=NULL)
    {
    temp.push_back(parent->data);
    }
    if(root->left)
    {
    temp.push_back(root->left->data);
    }
    if(root->right)
    {
    temp.push_back(root->right->data);
    }
    mp[root->data]=temp;
    getAdjacents(root->left,root,mp);
    getAdjacents(root->right,root,mp);
    }
    int minTime(Node* root, int start)
    {
    // Your code goes here
    unordered_mapmp;
    getAdjacents(root,NULL,mp);
    unordered_mapvis;
    queueq;
    int count=0;
    q.push(start);
    while(!q.empty())
    {
    int size=q.size();
    for(int i=0;i

  • @vinaysiwach9734
    @vinaysiwach9734 9 หลายเดือนก่อน

    i code this problem after watching just your algo

  • @anshikasingh4158
    @anshikasingh4158 ปีที่แล้ว

    boht mazza aaya pehle toh lga nhi ho paega pher yaad aaya -Just ask 1 question “ Why I started ?

    • @ihateracistandblackpeople4272
      @ihateracistandblackpeople4272 ปีที่แล้ว

      I also try to take that line to motivate me but that just doesn't work for me.Can you please tell what's that keeps you motivated or I should say why you started.

  • @dwivedi6037
    @dwivedi6037 2 ปีที่แล้ว

    Bhaiya aap great ho I have no words ♥️♥️ next level 😘😘😘😘😘😘😘😘😘😘😘😘😘😘😘😘

  • @adwitiy31
    @adwitiy31 9 หลายเดือนก่อน

    Here is a single function C++ code
    class Solution {
    public:
    int minTime(Node* root, int target)
    {
    if(root==NULL)
    {
    return 0;
    }
    map node_to_parent;
    queue q;
    q.push(root);
    node_to_parent[root] = NULL;
    Node* ans = NULL;
    while(!q.empty())
    {
    Node* temp = q.front();
    q.pop();
    if(temp->data == target)
    {
    ans = temp; // target is found
    }
    if(temp->left != NULL)
    {
    node_to_parent[temp->left] = temp;
    q.push(temp->left);
    }
    if(temp->right!=NULL)
    {
    node_to_parent[temp->right] = temp;
    q.push(temp->right);
    }
    }
    // ans is found
    map visited;
    visited[ans] = true;
    int time = 0;
    queue q1;
    q1.push(ans);
    while(!q1.empty())
    {
    int size = q1.size();
    bool flag = false;
    for(int i=0;ileft!=NULL && visited[t1->left]!=1)
    {
    flag = true;
    visited[t1->left] = true;
    q1.push(t1->left);
    }
    if(t1->right!=NULL && visited[t1->right]!=1)
    {
    flag = true;
    visited[t1->right] = true;
    q1.push(t1->right);
    }
    if(node_to_parent[t1]!=NULL && visited[node_to_parent[t1]]!=1)
    {
    flag = true;
    visited[node_to_parent[t1]] = true;
    q1.push(node_to_parent[t1]);
    }
    }
    if(flag)
    {
    time++;
    }
    }
    return time;
    }
    };

  • @sukhpreetsingh5200
    @sukhpreetsingh5200 2 ปีที่แล้ว +1

    done bhaiya

  • @AbhishekGupta-tn8sp
    @AbhishekGupta-tn8sp ปีที่แล้ว

    class Solution {
    private:
    unordered_map node2Parent;
    unordered_map visited;
    queueq;
    Node* targetNode = NULL;
    int time = 0;
    //step 1: create node 2 parent mapping via level order traversal
    //and also try to find target node
    void getNodeToParent(Node* root, int target){
    queueaux;
    aux.push(root);
    while(!aux.empty()){
    Node* curr = aux.front();
    aux.pop();
    //checking if current node is target node
    if(curr->data == target){
    targetNode = curr;
    }
    //set parent of root to null
    if(curr==root){
    node2Parent[root]=NULL;
    }
    if(curr->left){
    node2Parent[curr->left] = curr;
    aux.push(curr->left);
    }
    if(curr->right){
    node2Parent[curr->right] = curr;
    aux.push(curr->right);
    }
    }
    }
    void burning(){
    while(!q.empty()){
    Node* curr = q.front();
    q.pop();
    if(curr==NULL){
    time++;
    if(!q.empty()){
    q.push(NULL);
    }
    }
    else{
    visited[curr]=true;
    // Check for left node
    if(curr->left && !visited[curr->left]){
    q.push(curr->left);
    }
    // Check for right node
    if(curr->right && !visited[curr->right]){
    q.push(curr->right);
    }
    // Check for parent node
    Node* parent = node2Parent[curr];
    if(parent && !visited[parent]){
    q.push(parent);
    }
    }
    }
    }

    public:
    int minTime(Node* root, int target)
    {
    getNodeToParent(root,target);
    q.push(targetNode);
    q.push(NULL);
    burning();
    return time-1;
    }
    };

  • @shivkumar-og4ow
    @shivkumar-og4ow 2 ปีที่แล้ว +1

    Thank you bhaiya..
    Consistency ++

  • @madetolaugh3476
    @madetolaugh3476 2 ปีที่แล้ว

    Consistency....Prathishta...Anushaashan....

  • @hardiksingh8344
    @hardiksingh8344 11 หลายเดือนก่อน

    bhaiya codes k link? github pr apne aage k nhi upload kiye

  • @codingcouch
    @codingcouch 2 ปีที่แล้ว +1

    Baaki sb to theek hai, but you never taught people debugging!

  • @Shivam_guru
    @Shivam_guru 2 หลายเดือนก่อน

    bhaiya iske source code kaha hai???? github pe nahi dikh raha hai

  • @yashchampaneri1972
    @yashchampaneri1972 2 ปีที่แล้ว +1

    26:27 😁😁😂😂 kyu tum log ne vahi suna jo mene sunna ?

  • @muhammadsuleman8936
    @muhammadsuleman8936 ปีที่แล้ว

    Thanks brother for such amazing contenet

  • @DivyanshuYadav-t7l
    @DivyanshuYadav-t7l 7 หลายเดือนก่อน

    better than striver's explanation

  • @deepak44222
    @deepak44222 ปีที่แล้ว +1

    happy married life to you bhaiya. 😁😁😁😁😂😂😂😂

  • @vivekrathore6030
    @vivekrathore6030 ปีที่แล้ว +8

    full code :)
    class Solution {
    public:
    //step-1 create mapping and return the target node
    Node* createParentMapping(Node* root,int target,map &nodeToParent){
    Node* res = NULL; //to store the result;
    queue q;
    q.push(root);
    nodeToParent[root] = NULL;
    while(!q.empty()){
    Node* front = q.front();
    q.pop();
    if(front->data==target){
    res = front;
    }
    if(front->left){
    nodeToParent[front->left] = front;
    q.push(front->left);
    }
    if(front->right){
    nodeToParent[front->right] = front;
    q.push(front->right);
    }
    }
    return res;
    }
    int burnTree(Node* root,map &nodeToParent){
    map visited;
    queue q;
    q.push(root);
    visited[root] = true;
    int ans = 0;
    while(!q.empty()){
    bool flag = 0;
    int size = q.size();
    for(int i=0;ileft && !visited[front->left]){
    flag = 1;
    q.push(front->left);
    visited[front->left] = 1;
    }
    if(front->right && !visited[front->right]){
    flag = 1;
    q.push(front->right);
    visited[front->right] = 1;
    }
    if(nodeToParent[front] && !visited[nodeToParent[front]]){
    flag = 1;
    q.push(nodeToParent[front]);
    visited[nodeToParent[front]] = 1;
    }
    }
    if(flag==1){
    ans++;
    }
    }
    return ans;
    }
    int minTime(Node* root, int target)
    {
    map nodeToParent;
    Node* targetNode = createParentMapping(root,target,nodeToParent);
    int ans = burnTree(targetNode,nodeToParent);
    return ans;
    }
    };

  • @Bhagwati_Jewellers.
    @Bhagwati_Jewellers. 2 ปีที่แล้ว +1

    Amazing bhiaya 🙏

  • @naveensingh_0735
    @naveensingh_0735 2 ปีที่แล้ว

    We will make you proud

  • @abhijeetgorai65
    @abhijeetgorai65 2 ปีที่แล้ว +1

    bhai code ki link nahi daali kya github me?

  • @sherebanoburhani8939
    @sherebanoburhani8939 2 ปีที่แล้ว

    Present bhaiya❤

  • @divyamvijay9071
    @divyamvijay9071 ปีที่แล้ว

    You are really doing great for us bhaiya ❤❤❤

  • @zishan53
    @zishan53 2 ปีที่แล้ว +1

    Great 😃👍👍👍 fantastic

  • @tanishkayadav7351
    @tanishkayadav7351 2 ปีที่แล้ว

    learning from the best!

  • @jericodcosta2049
    @jericodcosta2049 2 ปีที่แล้ว +1

    Attandance marked thankyou

  • @deepakvaishnav9780
    @deepakvaishnav9780 2 ปีที่แล้ว

    Que1 Bhaiya jb pointers pd rhe the tb aapne btaya tha ki pointer ko ( int* p;) is tarike se initialise krna bad practice h kyoki isme koi garbage value aa jaegi jo shayad koi confidential data bhi ho skta h... Lekin linked list ke implementation me fir (Node* next;) ye kyu initialise kiya?????????
    Que2 insertion at last node kr time bhi last node ke pointer ko null se hta kr new node ko point krvate h, lekin pointer me dekha tha ki null vector ki value change nhi kr skte????
    Que3 jese array ke case me *arr krte the to uska data milta tha vese linked list me kisi bhi next ko dereference krke yani *next krke access kre to kya next node ka data milega???
    Que 4 kya mujhe pointer vapas revise krna chahiye 🤣🤣

    • @pradipsinhdarbarofficial2098
      @pradipsinhdarbarofficial2098 2 ปีที่แล้ว

      Ans1 we have not initialised it by (Node * next); it's just class structure saying that the object of this class will have this property called next which is pintor of node....we later initialised it in constructor making it NULL like (this->next = NULL) at this time we are initialising it.not earlier...
      Ans2 --> we cannot excess data of null vector but we can always change the direction of null vector means When we are adding a node at the end of LL, we are changing last node's next vector from NULL to the new Node (node's address as next is a pointor of node so we can only save address in it )

    • @deepakvaishnav9780
      @deepakvaishnav9780 2 ปีที่แล้ว

      @@pradipsinhdarbarofficial2098 thanks bro.. 3rd question bhi check krke dekho please mere pas laptop ya pc nhi h

    • @devanshbatra308
      @devanshbatra308 2 ปีที่แล้ว

      @@pradipsinhdarbarofficial2098 Thanx for the explanation

  • @sumitchakrabortystudy651
    @sumitchakrabortystudy651 2 ปีที่แล้ว

    labrador traversal🤣🤣🤣🤣. btw noicely explained

  • @vinayaksinghal
    @vinayaksinghal 10 หลายเดือนก่อน

    class Solution {
    private:
    TreeNode*f(TreeNode* root, int start,map&mpp){
    mpp[root]=NULL;
    TreeNode*target=NULL;
    queueq;
    q.push(root);
    while(!q.empty()){
    TreeNode*front=q.front();
    q.pop();
    if(front->val==start){
    target=front;
    }
    if(front->right){
    mpp[front->right]=front;
    q.push(front->right);
    }
    if(front->left){
    mpp[front->left]=front;
    q.push(front->left);
    }
    }
    return target;
    }
    int g(TreeNode*target,map&mpp){
    mapvis;
    vis[target]=1;
    queueq;
    int ans=0;
    q.push(target);
    while(!q.empty()){
    int size=q.size();
    bool flag=0;
    for(int i=0;iright && !vis[front->right]){
    flag=1;
    vis[front->right]=1;
    q.push(front->right);
    }
    if(front->left && !vis[front->left]){
    flag=1;
    vis[front->left]=1;
    q.push(front->left);
    }
    if(mpp[front] && !vis[mpp[front]]){
    flag=1;
    vis[mpp[front]]=1;
    q.push(mpp[front]);
    }
    }
    if(flag==1){
    ans+=1;
    }
    }
    return ans;
    }
    public:
    int amountOfTime(TreeNode* root, int start) {
    mapmpp;
    TreeNode*target=f(root,start,mpp);
    int ans=g(target,mpp);
    return ans;
    }
    };

  • @codingaid2753
    @codingaid2753 2 ปีที่แล้ว

    Thanks bhaiya for easy and nice explanation👏

  • @naveensingh_0735
    @naveensingh_0735 2 ปีที่แล้ว

    Words aren't enough bade bhaiya 🙏

  • @AnilKumar-bq9yo
    @AnilKumar-bq9yo 2 ปีที่แล้ว

    why take Visited map instead of visited array???

  • @RohitSingh-hc8yi
    @RohitSingh-hc8yi ปีที่แล้ว +1

    Attendance marked

  • @abhishekshimpi214
    @abhishekshimpi214 ปีที่แล้ว

    Maza hi agya bhaiyya🤩🤩🔥🔥

  • @ravivishvas3676
    @ravivishvas3676 2 ปีที่แล้ว

    best content ever...

  • @kalpeshmali1476
    @kalpeshmali1476 2 ปีที่แล้ว

    Shandar bhaiya

  • @aryankr
    @aryankr 7 หลายเดือนก่อน

    bohot bohot shukriya