Count of good nodes | Leetcode

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 ต.ค. 2024

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

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

    just at 2:29 i understood the concept. You have some magic bro. I didnt see the whole video, it just clicked at that particaluar time..thanks

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

    Please drop 60fps to 30 for high res uploads (720p and 1080p).
    There is no need for super high refresh rate for tutorials.
    It lags badly when jumping between parts of the video.

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

    Thanks for the great lecture as always!

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

    in order to maintain max at each node we need some datastructure with out searching whole path again and again.
    i think max stack will give optimal time.
    correct me if I'm wrong.😊

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

    anybody who want still less cody approach ... btw it is same as explained in video
    void call(TreeNode* root,int &count,int nx)
    {
    if(root->val>=nx)
    {
    count++;
    nx=root->val;
    }
    if(root->left) call(root->left,count,nx);
    if(root->right) call(root->right,count,nx);
    }

    int goodNodes(TreeNode* root) {
    int count =0;
    call(root,count,-1e4);
    return count;
    }