This video i watched a year ago definitely got me my job now in my final year. You taught so well i was able to recollect every approach from this. So thanks a ton.
The best part of his videos is: he explains from starting tells all expected approaches and their disadvantages and finally tells approach that will give the correct answer and then gives the solution. Hats off!!!!
Man, Teacher's day never made sense to me before but now after watching these videos, my thinking has changed completely. If teachers in India can focus on developing the thought process in students rather than just completing the syllabus and getting their students in merit list, a lot can change in the country.
Great video. Damn amazing. You can't imagine what great service you are delivering. I get the idea and I even figure out the whole code in between the video. This is the sign of a great teacher. He just need to give a sign to the student, and the rest becomes a story. You gave me the true picture of what is APPROACH. Otherwise, I was just understanding the idea of the problem or just memorizing how to solve it. You are a CODING GOD.
Bro i really wish i found out about u sooner currently 6th sem passed and watching ur videos for recap......best teacher by far! Mad respect bhaiya!:))
Aadi bhai you rock yarr.. !! Bhai aapka teaching style todd hai.. ek baar dekhte hi sab samaz aata hai.. bahot dua lagne wali hai aapko sabki.. You doing a commendable job..!! Hats off yarr..!! I hated DS Algo kyunki mujhe bahot tough lagta tha ye sab.. pr ab nahi.. sala kash kisine aisa angle dikhaya hota pehle.. I love solving problems now and successfully able to find patterns in it. Thanks, man..!! Keep up the good work..!! Waiting for more..!! God bless.. :-)
Thanks brother !! Such long comments always put a smile across my face ❤️✌️✌️ Also Do share the content amomg your friends and collage to help the channel grow !! Thanks for watching again !!
Today I got selected in Flipkart all because of your videos Aditya! Besides learning technical stuff, I got to learn from you on how to handle and approach complex problems. Thanks a lot! I really owe you a lot, can't msg on LinkedIn since you haven't accepted my request but I'm gonna ping you as soon as I join to thank you :)
Very good approach Of breaking down water level at each building level. Minor enhancement: the last loop just to calculate sum can be eliminated. You can instead keep adding to sum right after you calculate water level at index i. sum += water[i]; // after calculating water[i]
leetcode solution for reference - for noobies like me !! int trap(vector& arr) { int n =arr.size(); vector right_max(n); vector left_max(n); // no matter what we can't store water on edge buildings left_max[0]=arr[0]; for(int i=1;i=0;i--){ right_max[i]=max(arr[i],right_max[i+1]); } int sum=0; for(int i=1;i
in case someone needs a java solution: class Solution { public int trap(int[] height) { int n = height.length; int[] maxL = new int[n]; int[] maxR = new int[n];
maxL[0] = height[0]; for(int i = 1; i < n; i++){ maxL[i] = Math.max(maxL[i-1], height[i]); } maxR[n-1] = height[n-1]; for(int i = n-2; i >= 0; i--){ maxR[i] = Math.max(maxR[i+1], height[i]); }
Commendable work of finding patterns and categorising problems. When will you be adding the last four problems of the list you shared in the beginning of the playlist?
bhai jitni tarif karu utni kam hai kya content share karte ho aap , ye channel god ka gift hai mere liye aur Aditya verma ( vishnu avatar hai mere life ke liye )
Arreyy ni bhai, kaha Vishnuji aur kaha me 😅 Michael Faraday kese bnna hai bs wo bta do 😂✌️ jokes apart, Thanks for such a beautiful comment, Love you brother 😅✌️
👏 Never thought DSA could be so much interesting and easy to learn. These aren't easy problems but hats off to you, after seeing your explanation it's a piece of cake ✌
can you please help me ? I wrote the whole code but it is giving me segmentation fault , i cant find where is the mistake #include #include #include using namespace std; #include int trap(vector& height) { vectormaxl; vectormaxr; maxl[0]=height[0]; for ( int i =1;i=0;i--) { maxr[i]=max(maxr[i+1],height[i]); } vectorwater; for ( int i =0;i
Thanks a lot for the awesome explanation. I was able to code only by listening to the explanation without seeing the solution. Please keep this channel organic with such content unlike others who at a later stage adulterate their channel with ads and shortcut videos.
There is O(1) space complexity solution to it. This is indeed related to NGL just nearest is changed to farthest. In fact there is no need of stack in NGL, you can just use the same technique to compare with ngl(previous).
I don't think we can say this as farthest greater to left: suppose this is the array: 6 8 0 0 5 9 6 for element=5 max in the left array is 8 max in the right array is 9 min of both is 8 water accumulated on element =5 is 8-5=3. which is correct. But, farthest greater to left is 6 farthest greater to right is 9 min is 6 water accumulated is 6-5 =1, which is wrong
Good Explanation Programming Lord! But Bro, please create the remaining ones in the list, really appreciate your hard work for explaining the concepts. I wished my DSA teacher be like you.
no doubt , he gave an amazing explanation, but we didn't used stack in this solution, then what's the point of adding this question in the stack playlist?
Yaar mera to dhyaan bhatak jaata hai ...beech beech may pause kar k bs dil pe haath rakh k hsate rehta hun......kitniiii ppyaari hai ye.... lekin han bahot achcha pdhati hai jenny mam
Sir i am being your big fan saala puri duniya patani lakhon kharch karke lecture video suit kar raha he aur bhai apna ek page aur mobile phone se unn sabki le raha he.. God Bless bhai.. Love you..
I have a doubt here, we didn't use Stacks at all in this solution. I see a stack solution on GFG as well but I can't grasp that, can you please add an explanation for that as well?
Thanks Aditya . Constant space - O(1). and single loop solution - O(n) void max_water(int A[], int n) { int l = 0, h = n - 1; int left_max = 0; int right_max = 0; int ans[n] = {0}; while (l = right_max) { right_max = A[h]; } else ans[h] = right_max - A[h]; h--; } } for (int i = 0; i < n; i++) { cout
This problem clearly identifies stack . as we go maxleft and maxright element comparing to the current element. So seen the full video and disappointed by not using stack. So I implemented the Stack-based approach its is similar to NGL and NGR but little modifications need to be done.and also similar to above video approach but below code uses stack and above code uses max(arr[i],max[i-1]); Note:-All my knowledge is acquired from Aditya verma's channel. JAVA CODE class Solution{ // arr: input array // n: size of array // Function to find the trapped water between the blocks. static int trappingWater(int arr[], int n) { int sum=0; int maxright[]=maxRight(arr,n); int maxleft[]=maxLeft(arr,n); for(int i=0;i=0;i--) { if(st.peek()
we don't really need to implement stack in this problem if we use stack our space complexity increases without any benefit so we can just do it using traversing and creating two array instead of stack
faltu ka oversmart bann raha hai jaise koi reimann hypothesis ka solution nikal diya ho, jab jarurat nahi hai stack ki aur O(1) space mein bhi hoskta hai toh faltu mein stack kyu ghusedna hai, push pop push pop karne mein maza arha h kya terko
Upvoting because you explained it well, but the video pic (in the starting) mentions, you will be solving it using stack, but you didn't. Please add the stack solution as well.
Just pointing out small error.. We should not add the contribution of negative values of water array in the final sum. Because it is be possible that the current building height may be greater than both the corresponding mgr and mgl values. In that case water array will become negative.
yeah this is an error in his explanation. While checking the according mxl and mxr values of arr[i], we will include arr[i] in that also. Cause if we check the answer through his explanation (not code) of this arr = [3, 0, 0, 5, 0 4] it'll be wrong.
I don't think so his solution is wrong in any way. See if there's a building whose height is the maximum one, then it's mgr and mgl is equal to the height of that building itself. And the amount of water on such a building will come out to be zero. So, in no ways the water array can hold a negative value .
is there a chance they way u setup the initial element of the maxl and maxr arrays is wrong? shouldnt the first element of maxl be 0 and the last elem of maxr be 0, since they are surrounded by buildinggs of height 0 and you only look in the left subarray and right subarray and never actually include the element you are on?
can you please help me ? I wrote the whole code but it is giving me segmentation fault , i cant find where is the mistake #include #include #include using namespace std; #include int trap(vector& height) { vectormaxl; vectormaxr; maxl[0]=height[0]; for ( int i =1;i=0;i--) { maxr[i]=max(maxr[i+1],height[i]); } vectorwater; for ( int i =0;i
can you please help me ? I wrote the whole code but it is giving me segmentation fault , i cant find where is the mistake #include #include #include using namespace std; #include int trap(vector& height) { vectormaxl; vectormaxr; maxl[0]=height[0]; for ( int i =1;i=0;i--) { maxr[i]=max(maxr[i+1],height[i]); } vectorwater; for ( int i =0;i
awesome sir, koi word nhi hai apki tarrif krna ka bss jaab selection honne ke baad sweet lekr faculty k pass too pta nhi jaoga ya nhi but appke pass jurur aaoga :-)
This video i watched a year ago definitely got me my job now in my final year. You taught so well i was able to recollect every approach from this. So thanks a ton.
Great explanation, and u r right jenny mam is pretty😂
right? You feel me ? !! 😂😂😂😂😂😂😂😂😂😂😂
@@TheAdityaVerma yup😂🙏, waiting for ur videos though
@@TheAdityaVerma awaaz bhi unka kitna pyaara hai
@@TheAdityaVerma hahhah
haha she is theory teacher. whenever i see her video i thought seh never coded in her whole life.
Jenny kafi achchha padati hai +sunder bhi dikhti hai!
Koi kinta bhi achcha DSA karle aakhir meh rehata engineer he hai 😂😂
men will be men...sargam lolol
😂😂
Exam me pass hone ke liye jada tar padhte hai
The best part of his videos is:
he explains from starting
tells all expected approaches and their disadvantages
and finally tells approach that will give the correct answer
and then gives the solution.
Hats off!!!!
15:50 we understand the double meaning laughter 😂😂😂
😂😂😂😂😂.... Are are sir 😭😭😭😂😂😂
kaise pani nikal na hai
jenny ka pani
Volume is very low sir please try to keep it a little more 😅
bhaii boats ke headphones se hi sunai de rha merko
Thanks for this comment, else I would consider this class as mute!
2:12 "dekhna hai to jaaker JENNY k lecture dekho dikhti bhi sundar hai aur acha bhi padhati hai"
Has a separate fanbase in my college
Man, Teacher's day never made sense to me before but now after watching these videos, my thinking has changed completely. If teachers in India can focus on developing the thought process in students rather than just completing the syllabus and getting their students in merit list, a lot can change in the country.
Great video. Damn amazing. You can't imagine what great service you are delivering. I get the idea and I even figure out the whole code in between the video. This is the sign of a great teacher. He just need to give a sign to the student, and the rest becomes a story. You gave me the true picture of what is APPROACH. Otherwise, I was just understanding the idea of the problem or just memorizing how to solve it. You are a CODING GOD.
You are right 😁
Bro how can i use pair in java ?? Actually I am in doubt
Bro i really wish i found out about u sooner currently 6th sem passed and watching ur videos for recap......best teacher by far!
Mad respect bhaiya!:))
Where did you get placed?
Aadi bhai you rock yarr.. !!
Bhai aapka teaching style todd hai.. ek baar dekhte hi sab samaz aata hai.. bahot dua lagne wali hai aapko sabki..
You doing a commendable job..!! Hats off yarr..!!
I hated DS Algo kyunki mujhe bahot tough lagta tha ye sab.. pr ab nahi.. sala kash kisine aisa angle dikhaya hota pehle.. I love solving problems now and successfully able to find patterns in it. Thanks, man..!!
Keep up the good work..!! Waiting for more..!! God bless.. :-)
Thanks brother !! Such long comments always put a smile across my face ❤️✌️✌️
Also Do share the content amomg your friends and collage to help the channel grow !! Thanks for watching again !!
@@TheAdityaVerma Needless to say.. already shared and received a lot of praise for sharing..!! :D :P
Thanks a ton !!
@@TheAdityaVerma bro thoda jor se bola kr pls..
Today I got selected in Flipkart all because of your videos Aditya!
Besides learning technical stuff, I got to learn from you on how to handle and approach complex problems.
Thanks a lot!
I really owe you a lot, can't msg on LinkedIn since you haven't accepted my request but I'm gonna ping you as soon as I join to thank you :)
apna LinkedIn ka profile do to
@@crajeducation6733 😂😂
@@crajeducation6733nhi laga lagta hai
Aditya sir is in flipkart too. Hope you get to meet him
Very good approach Of breaking down water level at each building level.
Minor enhancement: the last loop just to calculate sum can be eliminated. You can instead keep adding to sum right after you calculate water level at index i.
sum += water[i]; // after calculating water[i]
bhai ye toh stack ka sawal tha hi nhi
Aditya sir ke aagey mahaanta dikhaaega neech aadmi, jaa jaake ppap dho ganga mein
leetcode solution for reference - for noobies like me !!
int trap(vector& arr) {
int n =arr.size();
vector right_max(n);
vector left_max(n);
// no matter what we can't store water on edge buildings
left_max[0]=arr[0];
for(int i=1;i=0;i--){
right_max[i]=max(arr[i],right_max[i+1]);
}
int sum=0;
for(int i=1;i
Thanks
in case someone needs a java solution:
class Solution {
public int trap(int[] height) {
int n = height.length;
int[] maxL = new int[n];
int[] maxR = new int[n];
maxL[0] = height[0];
for(int i = 1; i < n; i++){
maxL[i] = Math.max(maxL[i-1], height[i]);
}
maxR[n-1] = height[n-1];
for(int i = n-2; i >= 0; i--){
maxR[i] = Math.max(maxR[i+1], height[i]);
}
int[] water = new int[n];
for(int i = 0; i
Sir, you said you would add the remaining videos later in the playlist. So can you please add them? They are really helping us. Thanks a lot.
15:52 that 😈 smile...😁😁😁
sir please complete the series , it is much needed. Hats off to your explanation ! if possible add queue playlist also
Explanation was really amazing, but where did we use stack.
Commendable work of finding patterns and categorising problems. When will you be adding the last four problems of the list you shared in the beginning of the playlist?
waitingggggg
Bhaiya on fire....jenny sundar b lagti h
2:10 had me going 😂😂😂
when are you releasing backtracking playlist?
It took him 3 years
Great explanation and Jenny sundar bhi dikhti h savage 😂😂😂😂
Was confuse with this example
1,0,2,0,1,3,1
kaafi achi padathi hai aur sundar bhi dikthi hai..😂😂
bhai jitni tarif karu utni kam hai kya content share karte ho aap ,
ye channel god ka gift hai mere liye aur Aditya verma ( vishnu avatar hai mere life ke liye )
Arreyy ni bhai, kaha Vishnuji aur kaha me 😅 Michael Faraday kese bnna hai bs wo bta do 😂✌️
jokes apart, Thanks for such a beautiful comment, Love you brother 😅✌️
15:52😅😂
🙊🙊😂😂
😂
"Apne ko kya hai, apne ko toh bas paani nikaalna hai" 🤣
👏 Never thought DSA could be so much interesting and easy to learn. These aren't easy problems but hats off to you, after seeing your explanation it's a piece of cake ✌
The current solution is O(N), O(N) for time and space complexity respectively. A more optimized solution exists using constant extra space O(N), O(1).
can you please help me ? I wrote the whole code but it is giving me segmentation fault , i cant find where is the mistake
#include
#include
#include
using namespace std;
#include
int trap(vector& height) {
vectormaxl;
vectormaxr;
maxl[0]=height[0];
for ( int i =1;i=0;i--)
{
maxr[i]=max(maxr[i+1],height[i]);
}
vectorwater;
for ( int i =0;i
you nailed it!!! I liked the way you have broken the problem down and the concept of maxleft and maxright, awesome, thanks a lot!!!
Thanks a lot for the awesome explanation. I was able to code only by listening to the explanation without seeing the solution. Please keep this channel organic with such content unlike others who at a later stage adulterate their channel with ads and shortcut videos.
brother please complete the series by uploading 4 more questions that you gave in your 1 video of stack
Nobody can explain like you. Your explanations makes hardest problem to the easiest problem. Thanks for that
There is O(1) space complexity solution to it.
This is indeed related to NGL just nearest is changed to farthest.
In fact there is no need of stack in NGL, you can just use the same technique to compare with ngl(previous).
how we can solve it in O(1) ??
I don't think we can say this as farthest greater to left:
suppose this is the array: 6 8 0 0 5 9 6
for element=5
max in the left array is 8
max in the right array is 9
min of both is 8
water accumulated on element =5 is 8-5=3. which is correct.
But, farthest greater to left is 6
farthest greater to right is 9
min is 6
water accumulated is 6-5 =1, which is wrong
2:10 yaha boss bhi pighal gye 😂
15:45 so , apne ko smj aa gya ki kese Pani nikal skte h ..😂😂 anyone noticed that he laughed at that moment 😅😅
2:14 bhaiya op😂😂
class Solution {
public:
int trap(vector& height) {
int n = height.size();
vector maxLeft(n), maxRight(n), area(n);
maxLeft[0]=height[0];
for(int i=1;i=0;i--){
maxRight[i]=max(maxRight[i+1],height[i]);
}
for(int i=0;i
15:51 his laugh after "tho hame samajh a gaya ki hm kaise paani nikal skte h" Ture engineers😂😂 🙌
Good Explanation Programming Lord! But Bro, please create the remaining ones in the list, really appreciate your hard work for explaining the concepts. I wished my DSA teacher be like you.
was expecting the approach using stack. It's nowhere in the utube. DP approach is explained by everyone as it is easy.
no doubt , he gave an amazing explanation, but we didn't used stack in this solution, then what's the point of adding this question in the stack playlist?
2:10 comment on jenny was awesome 😎😎😂😂😂😂😂😂😂😂
15:48 kese pani nikal sakte he , and that laughter explains all 😂😂
And jenny sundar h 🤣🤣🤣
Yaar mera to dhyaan bhatak jaata hai ...beech beech may pause kar k bs dil pe haath rakh k hsate rehta hun......kitniiii ppyaari hai ye....
lekin han bahot achcha pdhati hai jenny mam
fuck off.. Aditya Verma is best
Bhai appse aacha koi nahi padtha UA-cam pe ♥️
jenny achha padhati h aur sundar bhi dikhti h🤣🤣🤣🤣
Sir i am being your big fan
saala puri duniya patani lakhon kharch karke lecture video suit kar raha he aur bhai apna ek page aur mobile phone se unn sabki le raha he.. God Bless bhai.. Love you..
I have a doubt here, we didn't use Stacks at all in this solution. I see a stack solution on GFG as well but I can't grasp that, can you please add an explanation for that as well?
2:13😂😂
😅
Bahut sundar😂
"jenny kafi acha padhati hai aur sundar bhi dikhti hai"
can't thankyou enough for these videos, I can't believe I am able to code faster only by understanding the approach.
This video helped me in solving the leetcode question of Rain water trapping. Thanks alot!
Thanks Aditya .
Constant space - O(1). and single loop solution - O(n)
void max_water(int A[], int n)
{
int l = 0, h = n - 1;
int left_max = 0;
int right_max = 0;
int ans[n] = {0};
while (l = right_max)
{
right_max = A[h];
}
else
ans[h] = right_max - A[h];
h--;
}
}
for (int i = 0; i < n; i++)
{
cout
Is it the dp solution??
@@kirtikhohal3313 Dp can not be done without memoisation. This is greedy ig..
"Vo accha pdhati hai, sundar bhi dikhti hai" was heart touching🤣🤣
what will be the time and space complexity for this problem??
Bhaiya mooj kara di 🔥🔥🔥 maza aagaya
Sir, please upload videos on graph problems: DFS, shortest paths, SCC
Still Waiting for Tree,Graph, Backtracking...
Bhai apko jab bhi time mile to inki video series bana ke upload kr dena🙏🙏🙏
areeey you're the best ..i can binge watch your videos
Get a life
one line for Jenny 😂
kaafi acha pdhati hai and sundar bhi dikhti hai 😂
This problem clearly identifies stack . as we go maxleft and maxright element comparing to the current element. So seen the full video and disappointed by not using stack. So I implemented the Stack-based approach its is similar to NGL and NGR but little modifications need to be done.and also similar to above video approach but below code uses stack and above code uses max(arr[i],max[i-1]);
Note:-All my knowledge is acquired from Aditya verma's channel.
JAVA CODE
class Solution{
// arr: input array
// n: size of array
// Function to find the trapped water between the blocks.
static int trappingWater(int arr[], int n) {
int sum=0;
int maxright[]=maxRight(arr,n);
int maxleft[]=maxLeft(arr,n);
for(int i=0;i=0;i--)
{
if(st.peek()
we don't really need to implement stack in this problem if we use stack our space complexity increases without any benefit so we can just do it using traversing and creating two array instead of stack
faltu ka oversmart bann raha hai jaise koi reimann hypothesis ka solution nikal diya ho, jab jarurat nahi hai stack ki aur O(1) space mein bhi hoskta hai toh faltu mein stack kyu ghusedna hai, push pop push pop karne mein maza arha h kya terko
Add link to problem in your videos.
TY for the amazing tutorials.
wow great problem, solved excellents, there's little maths involved but yea great explanation.
stack kha use hua isme?
Bhai stack kaha use kiya issme ??
Bro tumne khud sikhe ya phle pdhe
Mtlb one go n develop kiye k solution
Awesome work! Why put this in stack playlist?
check the comments section..
Upvoting because you explained it well, but the video pic (in the starting) mentions, you will be solving it using stack, but you didn't. Please add the stack solution as well.
Explanation is really good but i didn't see stack in this problem
@adityaverma Please discuss the time complexity also for each program ..please it will help a lot
aditya bhai, tum ho to sb h, vrna kch bhi nhi. dil se dhanyawaad
How come this problem comes under stacks concept?
Time complexity using this method and using stacks is O(n), right?
but here we have not used stacks?
Jenny kafi achchha padati hai +sunder bhi dikhti hai!
Sir aapka crush hai sayad😂
Tum log badnaam mt kro be, 😂😂 tum logo interest aaye isliye bola tha yaar, yaha to backfire ho gya 😕😅
Bhaiya mic mars pe rakh ke earth pe video record kar rahe ho kya.
can this be done without using extra space??
Just pointing out small error..
We should not add the contribution of negative values of water array in the final sum. Because it is be possible that the current building height may be greater than both the corresponding mgr and mgl values. In that case water array will become negative.
yeah this is an error in his explanation. While checking the according mxl and mxr values of arr[i], we will include arr[i] in that also. Cause if we check the answer through his explanation (not code) of this arr = [3, 0, 0, 5, 0 4] it'll be wrong.
I don't think so his solution is wrong in any way. See if there's a building whose height is the maximum one, then it's mgr and mgl is equal to the height of that building itself. And the amount of water on such a building will come out to be zero. So, in no ways the water array can hold a negative value .
Sharing my LeetCode for reference Passing 321/321 cases
int trap(vector& height) {
int c=height.size();
vector left(c),right(c);
int water=0;
left[0]=height[0];
for(int i=1;i=0;i--)
{
right[i]=max(right[i+1],height[i]);
}
for(int i=0;i
@@adityasoni3794 I just checked for this example, the code and logic is working fine for it, it's giving the desired output that is 10 units .
those who learned " pani kaise nikalte hai".....like the video
has pada tha bhai apna
Where is stack used in the video🙂
I love your explanation sir
Sundar bhi dikhti hai woh😂🥰🥰
15:46 ,me as a kid when friend told me about homework folder.
best explanation 🥳
no stack used right?
Similar to histogram but not stacks problem i think . Just arrays
Waiting eagerly for your backtracking playlist. Please release it soon.
samshj me agya kaise pani nikalna hai
thanks bhaiya for such a wonderfull explanation
is there a chance they way u setup the initial element of the maxl and maxr arrays is wrong?
shouldnt the first element of maxl be 0 and the last elem of maxr be 0, since they are surrounded by buildinggs of height 0 and you only look in the left subarray and right subarray and never actually include the element you are on?
Exactly my question
15:50 Bro didn't even hesitate!! 😂😂
itna acche se explain kiya hai. dhanyawaad.
can you please help me ? I wrote the whole code but it is giving me segmentation fault , i cant find where is the mistake
#include
#include
#include
using namespace std;
#include
int trap(vector& height) {
vectormaxl;
vectormaxr;
maxl[0]=height[0];
for ( int i =1;i=0;i--)
{
maxr[i]=max(maxr[i+1],height[i]);
}
vectorwater;
for ( int i =0;i
What an explanation 😊
Attitude tabar tor hai bhai sahi hai dikhra hai kis level ka preparation hai aur really approach kafi different aur accurate hai
Bhai gfg p isqe 5 solution h... To kya vo sArey krne pdege..? Ya fir bs ek o(n2) vala aur ek ye jo apne btaya h O(n) with using space...
can you please help me ? I wrote the whole code but it is giving me segmentation fault , i cant find where is the mistake
#include
#include
#include
using namespace std;
#include
int trap(vector& height) {
vectormaxl;
vectormaxr;
maxl[0]=height[0];
for ( int i =1;i=0;i--)
{
maxr[i]=max(maxr[i+1],height[i]);
}
vectorwater;
for ( int i =0;i
sunder bhi dikhti hai who😂, But you are the best!
bhai bohot badiya thi vedio :)
pr avaj bohot kam hai
jis karan earphone lagane pad te hai
aur jada time earphone lagane muskil hai
awesome sir, koi word nhi hai apki tarrif krna ka bss jaab selection honne ke baad sweet lekr faculty k pass too pta nhi jaoga ya nhi but appke pass jurur aaoga :-)
Why is this question included in the stack playlist? You didn't use stack anywhere in this question.
class Solution {
public:
int trap(vector& height) {
vectorleft(height.size());
vectorright(height.size());
left[0]=height[0];
right[height.size()-1]=height[height.size()-1];
for(int i=1;i=0;i--)
{
right[i]=max(right[i+1],height[i]);
}
vectorans(height.size());
for(int i=0;i
Bhai or SB topic pe videos dalo na .... Bhut Shi samjh Mai aata tumhari video se
But is main stack kahan laga? Ye problem stack ke playlist main kyun hai?