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
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;
}
};
Waiting for the Fenwick tree Class!!
Bro please do the fenwick tree also... And thank you for this wonderful video...
sir please do the Fenwick tree also... And thank you for this wonderful video...
One of the best Range query lec
such a great lecture. thanks Raj.
One of the best class for Segment tree
Amazing tutorial and thank you for the efforts!
waiting for fenwich tree masterclass!
sir fenwick tree ki class kab le rahe ho ?
bhai ye jo digit dp dikha tha startig me ye to aapne padhaya nahi kabhi bhi
the code link is not working?....can someone pls share the link or code here
i have code link,You need still??
@@mohammadajij8804 please provide it
fenwick ki class kb ayegi
Striver op
best
Fenwick tree sir??🥺🥺🥺
sir what about the fenwick trees sir :/