L48. Construct a BST from a preorder traversal | 3 Methods

แชร์
ฝัง
  • เผยแพร่เมื่อ 19 ก.ย. 2024
  • Entire DSA Course: takeuforward.o...
    Check our Website:
    Linkedin/Instagram/Telegram: linktr.ee/take...
    #treeSeries #striver #placements

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

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

    Please like and share among friends ^ _ ^
    Find all links in description!

    • @PrinceKumar-el7ob
      @PrinceKumar-el7ob 2 ปีที่แล้ว

      Thanks a lot striver !! Keep uploading .

    • @tanmaisaichennagiri5543
      @tanmaisaichennagiri5543 3 หลายเดือนก่อน +1

      Bro if we have to just return the root of the binary tree, then we can directly say that it’s the first element in that preorder array. 😛

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

    The red neon light kind of marker is cool. The way it disappears after every 2 sec😀

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

      no
      he makes it disappear look closely

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

      Which app is he using on ipad?

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

      @@saqlainkadiri Goodnotes

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

      @@mritunjay3723 no it disappears after you remove apple pencil from the ipad screen for more than 1 sec . It comes with good notes app

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

      🤣

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

    I coded this by my own from your detailed explanation, started clicking on your videos first whenever I search for a problem.
    Thanks buddy thanks a lot 😊

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

    the key point would be for above solution, for root.left pass root.val as bound and for root.right pass bound value as it is.
    great explanation bro. thanks

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

      Thanks for this. I really missed this key point.

  • @ravishkumar6060
    @ravishkumar6060 ปีที่แล้ว +14

    Striver's way of explaining problems itself solves more than 50% of the problem :)

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

    thank you so much the recursion tree really helped me to understand how return statement is working 🙏

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

    Approach 3 : Space Complexity Doubt
    Space Complexity in 3rd approach should be O(N) because of the recursive stack which takes up space of O(H) and in a skewed tree H = N.
    Here H = height of Tree
    N = Number of nodes in Tree

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

      recursive stack space is not an external space, thats why its O(1)

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

      I think some of the videos were made earlier compared to others (like this one). At that time probably he was not considering stack space of recursion as part of space complexity. But just in case anyone is confused this will be O(H) and aligned with his thought as seen in other videos. Hope this helps.

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

    The upper bound logic is brlliant

  • @stith_pragya
    @stith_pragya 10 หลายเดือนก่อน +1

    Thank You So Much for this wonderful video...............🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻

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

    Hi striver, love your videos. I have one que. How is the T.C in efficient solution is O(3N) and not O(N) as it is a basic dfs traversal? Does that mean that the dfs traversals like inorder/preorder take O(3N) time instead of O(N)?

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

      You are right. I also got this question.

    • @AbhishekKumar-vr7sh
      @AbhishekKumar-vr7sh 2 ปีที่แล้ว +6

      Yeah dfs traversal also takes O(3n) time to be precise but asymptotically it's linear time complexity

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

      for N -> infinity O(3N) is simplified to O(N). So it is linear time complexity.

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

      I have same doubt , But i think because all the statment inside fuction just executed ones Time complexity shoud be O(N) not not O(3N)

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

      It should be O(N) only because you can see each recursive function is getting executed only once not thrice.

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

    Did it using stack. Python code:
    class Solution:
    def bstFromPreorder(self, preorder: List[int]) -> Optional[TreeNode]:
    if not preorder:
    return None

    root = TreeNode(preorder[0])
    stack = [root]
    for value in preorder[1:]:
    node = TreeNode(value)
    if value < stack[-1].val:
    stack[-1].left = node
    stack.append(node)
    else:
    while stack and value > stack[-1].val:
    last = stack.pop()
    last.right = node
    stack.append(node)

    return root

  • @pratyayamrit7336
    @pratyayamrit7336 ปีที่แล้ว +6

    Can anyone explain why do we need to take array of int rather than just an int value of i ? Thanks !

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

      In java code ?
      Because in java, integer can only be passed by value, not by reference
      Hope it helps 🙂

  • @Yash-uk8ib
    @Yash-uk8ib 2 ปีที่แล้ว +6

    sir for 2nd method (inorder one), I think it should be guarateed that the nodes will be unique otherwise, complexity will increase.

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

      Bst means nodes are unique 😅

    • @Yash-uk8ib
      @Yash-uk8ib 2 ปีที่แล้ว +2

      @@takeUforward oh ok!! thanks for the clarification!!

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

    I used a stack to find the next greater element (right subtree)
    class Solution {
    public:
    TreeNode* create(vector& preorder, vector& nge, int i, int j){
    if(i > j){
    return NULL;
    }
    TreeNode* root = new TreeNode(preorder[i]);
    int rs = nge[i];
    root -> left = create(preorder, nge, i + 1, rs - 1);
    root -> right = create(preorder, nge, rs, j);
    return root;
    }
    TreeNode* bstFromPreorder(vector& preorder) {
    int n = preorder.size();
    stack st;
    vector nge(n);
    for(int i = n - 1; i >= 0; i--){
    while(!st.empty() and preorder[st.top()] < preorder[i]){
    st.pop();
    }
    if(st.empty()){
    nge[i] = n;
    }else nge[i] = st.top();
    st.push(i);
    }
    return create(preorder, nge, 0, n - 1);
    }
    };

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

      Exactly, this is what I though of!

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

    Your expressions are so good that you can also go into acting 😆

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

    python solution for the same hope this will help someone!!!
    class Solution:
    def bstFromPreorder(self, preorder):


    h = float(inf)
    self.i = 0

    def solve(preorder,h):
    if self.i == len(preorder) or h < preorder[self.i]: return None


    root = TreeNode(preorder[self.i])
    self.i += 1
    root.left = solve(preorder,root.val)
    root.right = solve(preorder,h)

    return root

    return solve(preorder,h)class Solution:

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

    the second method is actually running faster than third one

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

    9:58 reason why we don't consider lower bound

  • @codeman3828
    @codeman3828 4 หลายเดือนก่อน

    Loved the explanation

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

    instead of taking an array you can take a public variable 'i' as a data member for class solution and initialise it to 0 remove the third parameter like this
    class Solution {
    public int i = 0;
    public TreeNode bstFromPreorder(int[] preorder) {
    return bstfropreorder(preorder,Integer.MAX_VALUE);
    }
    public TreeNode bstfropreorder(int[] A,int bound){
    System.out.println(i);
    if(i==A.length || A[i]>bound) return null;
    TreeNode root = new TreeNode(A[i++]);
    root.left = bstfropreorder(A,root.val);
    root.right = bstfropreorder(A,bound);
    return root;
    }
    }

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

    nice solution

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

    Can we implement the 3rd method using stack? I think that will be more understandable..

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

    Beautiful code!

  • @pradipakshar
    @pradipakshar 9 หลายเดือนก่อน +3

    my mans got a lil conscious about the hair 8:18 🤣🤣🤣. Nice video as usual :)

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

    thank you

  • @dank7044
    @dank7044 3 หลายเดือนก่อน

    Did this on my own

  • @Learnprogramming-q7f
    @Learnprogramming-q7f 5 หลายเดือนก่อน

    Thank you Bhaiya

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

    cant believe you made it so fucking easy. man

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

    we love your content and we love you...🖤

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

    Thank you so much for providing this series .

  • @moksh7130
    @moksh7130 7 วันที่ผ่านมา

    In some problems you consider the recursion stack space in the space complexity and in some you don't. Anybody clear this doubt :D, appreciated

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

    without passing i as a reference can we do it in any other way because if we forgot to keep & symbol output will be wrong thanks in advance striver sir 🙂

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

      why did we use reference? why is it not working without reference?

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

      @@Cool96267 because while doing recursion I value has to be updated if we don't pass i by reference then output will be same values try yourself :)

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

      Yes, you can do by passing I as a variable of class.
      class Solution{
      int i = 0;
      //Code Here-> No need to pass i as an argument in functions.
      };

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

    can someone tell Why is variable i passed by reference??

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

      Because i is traversing the index of the vector . So once an element is traversed we need to move to next element and add it into the tree

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

      @@sushmitaraj6948 but we can also use pass by value right...because we're increasing the i value before passing it

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

    Can someone elaborate why the java code fails when we pass a variable instead or array in this case?? plz

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

      Because java does not support call by address.

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

    I did it using stack: Maximum height of stack will be height of tree
    class Solution {
    public:
    TreeNode* bstFromPreorder(vector& preorder) {
    stack s;
    int n = preorder.size();
    if(n == 0) return NULL;
    int i = 0;
    TreeNode* root = new TreeNode(preorder[i]);
    s.push(root);
    for(int i = 1; i < n; i++) {
    TreeNode* node = s.top();
    TreeNode* newNode = new TreeNode(preorder[i]);
    if(node->val > preorder[i]) {
    s.push(newNode);
    node->left = newNode;
    }
    else if(node->val < preorder[i]) {
    while(!s.empty() && s.top()->val < preorder[i]) {
    node = s.top();
    s.pop();
    }
    s.push(newNode);
    node->right = newNode;
    }
    }
    return root;
    }
    };

    • @gorilla_coder-el6kf
      @gorilla_coder-el6kf 11 หลายเดือนก่อน

      hey how did you think of this solution can you provide me the thought process or intuition pls

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

    Can we do another way for all nodes we find their correct postion to insert using bianry search and insert it - O(nlog(H))

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

    understood

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

    understood.

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

    Wat if we have 4 or a 3 after 7 in your example?

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

    In the first method we're just connecting the node in the bst just like normally inserting a node in a bst...is this always gonna give correct preorder bst

  • @VivekSharma-eh2tv
    @VivekSharma-eh2tv 2 หลายเดือนก่อน

    int the condition of or if i write a[i]>bound first , it gives me an error what is the reason behind this .. even the error cant be understood by me

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

    Very good explanation of the 3rd method

  • @surajbaranwal56.
    @surajbaranwal56. ปีที่แล้ว

    Thanks man for wonderful explanation.

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

    Why did he make the index a list and not an integer?

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

    at 3:51 why is it o(n*n) ? for every node, we are taking n time complexity? and n nodes , so O(n*n ) .

    • @CHANDANKUMAR-sg8cp
      @CHANDANKUMAR-sg8cp ปีที่แล้ว +1

      O(n*n) is for extreme case or worst case as in case of skew tree for each node u have to traverse every node

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

      @@CHANDANKUMAR-sg8cp wrong, even or skew tree the tc would be o(n). striver's first solution is talking about inserting nodes one by one, just like in the insert node in bst question. for every index in vector we would traverse the tree for logn time and insert the node at it's place. Still it would be nlogn and not n^2.

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

    understood ,able to solve by myself

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

    I really loved your content!!!

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

    Can bound be passed by reference?

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

    5:05 - 8:40 edoc: 14:04

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

    SAME JAVA SOLUTION - EASY TO UNDERSTAND 👇
    class Solution {
    private int index = 0;
    private TreeNode helper(int[] preorder, int upper_bound){
    if(index==preorder.length || preorder[index]>upper_bound){
    return null;
    }
    TreeNode root = new TreeNode(preorder[index]);
    index++;
    root.left = helper(preorder, root.val);
    root.right = helper(preorder, upper_bound);
    return root;
    }
    public TreeNode bstFromPreorder(int[] preorder) {
    return helper(preorder, Integer.MAX_VALUE);
    }
    }

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

    For Method 1 and 2 it's fine but for 3rd method how will a preorder array like -> [8,5,1,7,10,2] will run it will not give correct answer with your method i think please explain

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

      Same. Did you figure it out?

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

      The preorder is wrong bcz preorder is root-left-right so left is till 7 so after that all elements should be greater than 8(root) and in this input there is 2 which is incorrect.

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

      u need to pass the index as reference or declare it as a global variable

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

    Great Series

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

    Here to solve gate 2008 qs :)

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

    What an explanation!

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

    can anyone explain how the time complexity of 3rd solution is O(N)?....I thought it would be more than that...O(NlogN) worst case i think as the largest element will take O(logN) and for N nodes we will take O(NlogN) time in total.

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

    Thank you sir

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

    why we passed the i by reference ??

    • @abhinavgarg0077
      @abhinavgarg0077 4 หลายเดือนก่อน

      because the I value is changing at every iteration, that's why

  • @RISHABHKUMAR-w5z
    @RISHABHKUMAR-w5z 2 หลายเดือนก่อน

    why is the code so short

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

    thank you bhaiya!

  • @ChetanWani-be2ew
    @ChetanWani-be2ew 2 หลายเดือนก่อน

    We can declare ' i ' as global so need to pass and it contains current value ........right.......
    code is working
    class Solution {
    static int i=0;
    public static TreeNode helper(int[] preorder,int bound){
    if(i==preorder.length || preorder[i]>bound){
    return null;
    }

    TreeNode root=new TreeNode(preorder[i++]);

    root.left=helper(preorder,root.val);
    root.right=helper(preorder,bound);

    return root;
    }
    public TreeNode bstFromPreorder(int[] preorder) {
    i=0;
    return helper(preorder,Integer.MAX_VALUE);
    }
    }

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

    understooooood. thanks :)

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

    Bro, how many more videos will come of tree topic?

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

    done!

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

    intuition op!!!

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

    Iska time complexity smjh mein ni aya
    Backtracking ke liye alag se O(n) kiu le rahe ho

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

    BST inorded is always slrted

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

    Understood.

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

    Other approch ... not the range concept, no sorting even..
    class Solution {
    public:
    TreeNode* helper(vector& preorder,int ps,int pe){
    if(ps>pe)
    return NULL;
    TreeNode* root=new TreeNode(preorder[ps]);
    int r=preorder.size();
    for(int i=ps;ipreorder[ps]){
    r=i;
    break;
    }
    }
    root->left=helper(preorder,ps+1,r-1);
    root->right=helper(preorder,r,pe);
    return root;
    }
    TreeNode* bstFromPreorder(vector& preorder) {
    return helper(preorder,0,preorder.size()-1);
    }
    };
    can some one say whats the time complexity??

    • @jayakantpurushoth5650
      @jayakantpurushoth5650 3 หลายเดือนก่อน

      cheers!, I just thought the same way,
      guess the TC is still O(n)

    • @user-qq5bb7bh5z
      @user-qq5bb7bh5z 3 หลายเดือนก่อน

      i think O(N * N) as for every node we find the next greater element and in worst case we that elemwnt can be at last so thats that, you can also check in gfg were they have discussed same aproach

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

      ​@@user-qq5bb7bh5zexactly this is n^2 solution

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

    5:33

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

    I am a DSA beginner,is your trees series enough to crack tech giant's like Microsoft linkedin level companies?

    • @PrinceKumar-el7ob
      @PrinceKumar-el7ob 2 ปีที่แล้ว +1

      Ofcourse it is enough

    • @Yash-uk8ib
      @Yash-uk8ib 2 ปีที่แล้ว +3

      practice on ur own also buddy, not everything will be served to u!

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

      You need to drop out of college for getting into tech giants

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

    💚

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

    Video starts at 6:03

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

    6:11

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

    US

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

    ❤❤

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

    noice

  • @KaushikSharma-c3q
    @KaushikSharma-c3q 10 หลายเดือนก่อน

    ,.......................

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

    Method 3 samjh nhi aaya - tried 3 baar 😢

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

      pen paper pe dry run krke dekho, ayega samaj me

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

      @@anshumaan1024 yes i tried and got it
      but ig i still need more practice😅

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

    bhai tu pdata bhut bduya hai lekin , ye fake angrzi accent bhut annoying lgta hai , be natural man

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

    What will be the time complexity of this solution??Is this efficient??
    TreeNode* solve(TreeNode* root,int val)
    {
    if(root==NULL)
    root=new TreeNode(val);
    if(root->val>val)
    {
    root->left=solve(root->left,val);
    }
    if(root->valright=solve(root->right,val);
    }
    return root;
    }
    TreeNode* bstFromPreorder(vector& pre) {
    TreeNode* root=NULL;
    for(int i=0;i

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

      Time Complexity- O(nlogn) - as your are traversing the each node (total N nodes) using Binary search in height level and height of tree is Logn so total is nlogn.
      Space Complexity- O(H) average case...worst case is O(n)

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

    "us"

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

    Hey Striver love your videos been following since a long time. kudos to your hard work man. But as i saw the video the accent with which you explain kinda seemed to me that you are being a little arrogant/over-confident on yourself. May be its just me. But wanted to give you this constructive criticism hoping for better videos in future. This is just what i felt and thought of sharing. Please Don’t get offended. Thanks ☺️

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

      Nah nah, its the confience that i have covered in the previous videos.. haha thanks man..

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

      kyooo broo agar koiii best hai tum compare krlo.. striver hi hai to kyo na ho ghamand.. and i dont think its ego... if you you want to know what is ego just watch that kunal kushwahas videos you will know the difference buddy..

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

    It will not work if pre Oder is 100 200 20 80 50 60 40 10

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

      When my pointer is in right node 200 for 200 left part ub is 200 so 20 will be left child of 200 acc to your logic , but manually if we do 20 will be left part of top most root which is 100

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

    Next Video on Clarification about CP vs Development

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

      No already available bhai fltu videos ki demand q krte ho...ye sab Babbar Vagairah se kro

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

    plzzz let me know why is this code incorrect on leetcode, it's accepted on gfg.
    Node* post_order(int pre[], int size)
    {
    //code here
    int i = 0;
    return buildTree(pre, 0, size-1, 0);
    }
    Node* buildTree(int pre[], int preStart, int preEnd, int i){
    if(preStart > preEnd) return NULL;
    Node* root = newNode(pre[preStart]);
    for(; i pre[preStart]){
    break;
    }
    }
    root->left = buildTree(pre, preStart+1, i-1, preStart+1);
    root->right = buildTree(pre, i, preEnd, preStart+1);
    return root;
    }

  • @abhinanda7049
    @abhinanda7049 4 หลายเดือนก่อน

    understood

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

    Done!

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

    Understood

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

    Understood