Marathon Class on Range Query DS - 2 | Segment Trees | Fenwick Trees | Masterclasses By Striver

Поделиться
HTML-код
  • Опубликовано: 10 сен 2024
  • In this lecture, Raj (Striver) conducts a Masterclass for Range Query DS. Watch the full video to know more about Segment Trees & Fenwick Trees for the benefit of all the coding and programming aspirants. Let's Crack It!
    Relevel by Unacademy | Sign up now: relvl.co/se8h
    Introducing Relevel, India’s first Test hiring platform by Unacademy which is helping jobseekers find their dream jobs.
    Raj (Striver): CodeBeyond Learner Feedback Form - forms.gle/XLnL...
    👉🏼 Playlist: • Special Session | Code...
    Do Subscribe and be a part of the community for more such lessons here:
    👉🏼 Subscribe to our channel: bit.ly/3vFurOU
    👉🏼 Telegram: bit.ly/2WwFUop
    Use Special Code “STRIVER” to get a Free Sample Relevel Test Paper 😍
    👉🏻 Register today: relvl.co/se8h
    Educator profile: unacademy.com/...
    👉🏼 Subscribe today: unacademy.com/....
    👉🏼 Goal Upcoming Class page: unacademy.com/....
    ------------------------------------------
    Welcome to CodeBeyond - a new offering from Unacademy!
    Learn to code from the World's Top Experts/Coders and get your dream job.
    Our aim is to become a one-stop solution and bring to you a plethora of coding-related courses, hacks, information, and trends for all of you to reach your career goals.
    We have some of the best educators at Unacademy to help you build the knowledge and skills in your chosen field, right from a beginner to a pro-level!
    Subscribe to know more!
    Download the Unacademy Learning App here:
    👉🏼 Android: goo.gl/02OhYI
    👉🏼 iOS: goo.gl/efbytP
    Unacademy Subscription Benefits:
    1. Learn from your favorite Educator
    2. Dedicated DOUBT sessions
    3. One Subscription, Unlimited Access
    4. Real-time interaction with Educators
    5. You can ask doubts in a live class
    6. Limited students
    7. Download the videos & watch them offline
    #Range_Query #Segment_Trees #Fenwick_Trees #Programming

Комментарии • 20

  • @hritikanand9734
    @hritikanand9734 7 месяцев назад +4

    video waala code 👇👇👇👇
    class ST {
    vector seg, lazy;
    public:
    ST(int n) {
    seg.resize(4 * n);
    lazy.resize(4 * n);
    }
    public:
    void build(int ind, int low, int high, int arr[]) {
    if(low == high) {
    seg[ind] = arr[low];
    return;
    }
    int mid = (low + high) >> 1;
    build(2*ind+1, low, mid, arr);
    build(2*ind+2, mid+1, high, arr);
    seg[ind] = seg[2*ind+1] + seg[2*ind+2];
    }
    public:
    void update(int ind, int low, int high, int l, int r,
    int val) {
    // update the previous remaining updates
    // and propogate downwards
    if(lazy[ind] != 0) {
    seg[ind] += (high - low + 1) * lazy[ind];
    // propogate the lazy update downwards
    // for the remaining nodes to get updated
    if(low != high) {
    lazy[2*ind+1] += lazy[ind];
    lazy[2*ind+2] += lazy[ind];
    }

    lazy[ind] = 0;
    }

    // no overlap
    // we don't do anything and return
    // low high l r or l r low high
    if(high < l or r < low) {
    return;
    }

    // complete overlap
    // l low high r
    if(low>=l && high > 1;
    update(2*ind+1, low, mid, l, r, val);
    update(2*ind+2, mid+1, high, l, r, val);
    seg[ind] = seg[2*ind+1] + seg[2*ind+2];
    }
    public:
    int query(int ind, int low, int high, int l, int r) {

    // update if any updates are remaining
    // as the node will stay fresh and updated
    if(lazy[ind] != 0) {
    seg[ind] += (high - low + 1) * lazy[ind];
    // propogate the lazy update downwards
    // for the remaining nodes to get updated
    if(low != high) {
    lazy[2*ind+1] += lazy[ind];
    lazy[2*ind+2] += lazy[ind];
    }

    lazy[ind] = 0;
    }

    // no overlap return 0;
    if(high < l or r < low) {
    return 0;
    }

    // complete overlap
    if(low>=l && high > 1;
    int left = query(2*ind+1, low, mid, l, r);
    int right = query(2*ind+2, mid+1, high, l, r);
    return left + right;
    }
    };

  • @manikantsharma6108
    @manikantsharma6108 2 года назад +20

    Waiting for the Fenwick tree Class!!

  • @mjustboring
    @mjustboring 2 года назад +9

    Bro please do the fenwick tree also... And thank you for this wonderful video...

  • @saurabhjain1364
    @saurabhjain1364 2 года назад +4

    sir please do the Fenwick tree also... And thank you for this wonderful video...

  • @dhawalpatil7779
    @dhawalpatil7779 2 года назад +2

    One of the best Range query lec

  • @kashishsharma6809
    @kashishsharma6809 2 года назад +5

    such a great lecture. thanks Raj.

  • @shubhamgond2884
    @shubhamgond2884 Год назад

    One of the best class for Segment tree

  • @kunalsutar3946
    @kunalsutar3946 9 месяцев назад

    Amazing tutorial and thank you for the efforts!

  • @kms8320
    @kms8320 2 года назад +1

    waiting for fenwich tree masterclass!

  • @bipul544
    @bipul544 2 года назад +3

    sir fenwick tree ki class kab le rahe ho ?

  • @Deepakmishra-kv1kb
    @Deepakmishra-kv1kb 2 года назад +3

    bhai ye jo digit dp dikha tha startig me ye to aapne padhaya nahi kabhi bhi

  • @kousthubhtadanki1237
    @kousthubhtadanki1237 2 года назад +2

    the code link is not working?....can someone pls share the link or code here

  • @master_persi
    @master_persi 2 года назад +2

    fenwick ki class kb ayegi

  • @sahilanand30
    @sahilanand30 Год назад +1

    Striver op

  • @VishnuKumar-ig4rt
    @VishnuKumar-ig4rt Год назад

    best

  • @abhaypratapsrivastava4400
    @abhaypratapsrivastava4400 2 года назад +2

    Fenwick tree sir??🥺🥺🥺

  • @rohitn6333
    @rohitn6333 Год назад

    sir what about the fenwick trees sir :/