Leetcode 894. All Possible Full Binary Trees

แชร์
ฝัง
  • เผยแพร่เมื่อ 15 ก.ย. 2024
  • Use coupon ALISHA on any GeeksforGeeks course to get 10% discount:
    practice.geeks...
    Connect with me on LinkedIn : / alisha-parveen-80579850
    Check out our other playlists:
    Dynamic Programming:
    • Dynamic Programming
    Trees:
    • Trees
    Heaps and Maps:
    • Heaps and Maps
    Arrays and Maths:
    • Arrays and Maths
    Bit Manipulation:
    • Bit Manipulation
    Greedy Algorithms:
    • Greedy Algorithms
    Sorting and Searching:
    • Sorting and Searching
    Strings:
    • Strings
    Linked Lists:
    • Linked Lists
    Stack and Queues:
    • Stacks and Queues
    Two Pointers:
    • Two pointers
    Graphs, BFS, DFS:
    • Graphs, DFS, BFS
    Backtracking:
    • Backtracking
    Non- DSA playlists:
    Probability:
    • Probability
    SQL-Basic Join functions:
    • SQL - Basic JOIN Funct...
    SQL-Basic Aggregate functions:
    • SQL-Basic Aggregate Fu...

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

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

    unordered_mapdp;
    vector allPossibleFBT(int n) {
    if(n%2==0)return {};
    if(n==1)return {new TreeNode()};
    if(dp.find(n)!=dp.end())return dp[n];
    vectorans;
    for(int i=1;ileft = l;
    node->right = r;
    ans.push_back(node);
    }
    }
    }
    return dp[n] = ans;
    }

  • @bajrangsinha2546
    @bajrangsinha2546 7 หลายเดือนก่อน +1

    1) explanation up to mark, clear and concise.
    2) no asking for like and subscribe. That's why i liked and subscribed to your channel.
    3)quality content.
    4) after watching your videos it gives me more confidence in dsa.
    Thanks 🙏

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

    Thank you !! Almost every problem seems simpler after its explained by you!!

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

    It’s good to see you again 😊

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

    You're back!! And with leetcode premium this time. Bade log. Good to see you back.

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

    I recently discovered this channel
    Wow your explanation are so simple and good

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

    Was missing you 😅
    Leetcode Queen 👑

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

    nice to see you back your explanations are very good and on point

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

    amazing explanation. thank you.

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

    Thanks Alisha

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

    Happy belated teacher's day ma'am

  • @Idukhan-jj9kc
    @Idukhan-jj9kc ปีที่แล้ว +1

    Ma'am good to see🎉🎉please continue

  • @manishkumar-uw5mw
    @manishkumar-uw5mw ปีที่แล้ว +1

    Good to see you again 🥳🥳

  • @AnujSharma-ro4kc
    @AnujSharma-ro4kc ปีที่แล้ว +1

    Welcome back after sooo long 😊

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

    Welcome back!!

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

    One video on how to improve communication skills for coding interview

  • @DURGESHKUMAR-pu4wq
    @DURGESHKUMAR-pu4wq ปีที่แล้ว +7

    I thought you forgot your Chanel password 😂

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

    Thank you mam

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

    This channel is alive?

  • @HuzaifaBilal-fo7zc
    @HuzaifaBilal-fo7zc 5 หลายเดือนก่อน

    Make video on Print combinations of r elements in an array of size n

  • @ASHUTOSHSHARMA-h4w
    @ASHUTOSHSHARMA-h4w 5 หลายเดือนก่อน

    God made you beautiful and intelligent ❤. Thank you for the help

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

    finally after many days

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

    Welcome back☺☺

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

    When you completed yr btech and from where ?

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

    message to all learner, dont forget to subscribe to this channel.

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

    Fantastic 🎊👌👌

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

    Why is no one talking about time complexity ?

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

    can anyone pls share time complexity??? I am bit confused

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

    jai shree ram

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

    Are you alive Mam ?

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

    Didi did you got laid off from ms?

  • @ozzy-fr7vj
    @ozzy-fr7vj 26 วันที่ผ่านมา

    Rust implementation ->
    // Definition for a binary tree node.
    // #[derive(Debug, PartialEq, Eq)]
    // pub struct TreeNode {
    // pub val: i32,
    // pub left: Option,
    // pub right: Option,
    // }
    //
    // impl TreeNode {
    // #[inline]
    // pub fn new(val: i32) -> Self {
    // TreeNode {
    // val,
    // left: None,
    // right: None
    // }
    // }
    // }
    use std::{rc::Rc, cell::RefCell, collections::HashMap};
    type T = Option;
    macro_rules! treeNode {
    ($n:expr) => { Some(Rc::new(RefCell::new(TreeNode::new($n)))) };
    ($a:expr, $b:expr) => { Some(Rc::new(RefCell::new(TreeNode { val: 0, left: $a, right: $b, })))};
    }
    impl Solution {
    pub fn all_possible_fbt(n: i32) -> Vec {
    fn bk(n: i32, dp: &mut HashMap) -> Rc {
    match n {
    0 => dp.get(&0).unwrap().clone(),
    1 => dp.get(&1).unwrap().clone(),
    _ if dp.contains_key(&n) => dp.get(&n).unwrap().clone(),
    _ => {
    let mut res = Vec::new();
    for l in (1..n).step_by(2) {
    let r = n - 1 - l;
    for t1 in bk(l, dp).iter() {
    for t2 in bk(r, dp).iter() { res.push(treeNode!(t1.clone(), t2.clone())); }
    }
    }
    let res = Rc::new(res);
    dp.insert(n, res.clone());
    res
    }
    }
    }
    let result = bk( n, &mut HashMap::from([ (0, Rc::new(Vec::::new())), (1, Rc::new(vec![treeNode!(0)])), ]));
    Rc::try_unwrap(result).unwrap()
    }
    }