Thanks, man. @Aditya Verma Anyone who just watched the video for 5 minutes and they got the solution on their own should still like the video because He did hard work explaining it. And because of his previous videos, we were able to solve it.
@TheAdityaVerma4 жыл бұрын
Thanks brother, Do subscribe and share, that keeps me motivated to do more !!
@KeshavSingh-si4vm4 жыл бұрын
@@TheAdityaVerma I am at NIT Surathkal and currently preparing for internship interviews . You DP videos are helping me a lot .
@mohsinabbassayyed96103 жыл бұрын
@@TheAdityaVerma what if the given array is [100 86 78 89 1000]
@bhavyaratra54613 жыл бұрын
true
@mayankverma89893 жыл бұрын
@@mohsinabbassayyed9610 ngl of 1000 will be -1 and index of 1000 is 4 so if u do ngl index-i that is 4-(-1)=5 will be the answer
@Kirti-bi2yj6 ай бұрын
A more optimized solution, rather than storing pair in the stack, we can just solely store the NGL index itself, that will also work : vector calculateSpan(int price[], int n) { vector ans; stack s; for(int i=0; i
@aub17293 ай бұрын
dangg that's good!
@suyashdubey5204 жыл бұрын
Watching this again for nostalgia's sake.
@TheAdityaVerma4 жыл бұрын
😂😂😂😂
@AP-bk8vq4 жыл бұрын
Amazing work.. even paid courses don't have explanations anywhere near this level..Please make videos on Graph too!
@nishant52493 жыл бұрын
@@niru1931 agree
@raheman59133 жыл бұрын
@@niru1931 acha nahi hai kya bhai coding ninja
@aditya14-023 жыл бұрын
@@raheman5913 free hai???
@relaxcoder82283 жыл бұрын
@@aditya14-02 agree
@democratcobra2 жыл бұрын
100000 % agree.
@shivangirastogi15394 жыл бұрын
This is my first ever comment on you tube and without a single doubt your teaching skills make me do that. Great Work Man ☺️ Eagerly waiting for new playlists..
@TheAdityaVerma4 жыл бұрын
Thanks! 😅✌️
@dashrathsinghkaviya3 жыл бұрын
Bhaiya aap na main last year main hu tier 3 clg mein and maine dsa start kr rkhi h to stacks search kia to aapki videos mili...and aap manoge nhi mera concept itna awsm bn rha h na stacks mein ki kya hi btau...schi mein kafi shi pdhate ho aap... great job...keep it up... I've subscribed too... Thanks for making my concepts clear... FROM JAIPUR
@nikhil68423 жыл бұрын
I saw the explanation of this question in a very famous paid course. However they still failed to mention the intuition of arriving at this solution using stack, loved how you broke it into the NGL problem and the overall intuition behind it
@tarangranpara59134 жыл бұрын
the way you connected with NGL problem, hats off brother. you're an inspiration.
@ahishnar15683 жыл бұрын
Got the solution at 2:59 only, that how we can solve this. Great great great great great coding, programming, problem solving master. The only person who made not only dp but entire programming and problem solving easy. The guy who made entire programming and problem solving easy. Hats off to you bro. 🤘🤘🤘😀☺️🎉🎉🎉🙏🙏🙏🙏🙏🙏
@rishabhgupta7343 жыл бұрын
just commenting to remind you that even after 1 year this video is helping many people like me. KUDOS to you.
@mvabhinav19983 жыл бұрын
Awesome series. I was able to it myself 😃 I wish he made videos for rest of the topics as well. He is an amazing teacher !! Thankyou aditya
@divyanshusaxena1484 жыл бұрын
i bet IITians are watching videos of this NIT guy. Good going man.
@shades1799 Жыл бұрын
Me : IIT kgp 😂
@KingAkash.01 Жыл бұрын
Me IIT:not selected
@jatin_goyal Жыл бұрын
Me : Amity university
@priyanshkumar17 Жыл бұрын
Me : IIT Delhi
@Sm_iitp Жыл бұрын
Me . iitpatna
@dochimekashiariri76103 жыл бұрын
I found one more thing in my life to be thankful for 🥺.
@Ayush-bk3rv2 жыл бұрын
The first Four Foundation problem was a neat trick before getting to this problem, you made the viewer use his intuition to get to the solution.
@coding_bro4158 Жыл бұрын
i have not seen any playlist of this channel other than this stack playlist......but i must say, its killing it. My stack understanding and problem solving has improved a lot , every other channel like anuj bhaiya , love baber , khuswaha has not explained as clear as him. Thank u @Aditya Verma Bhaiya😇
@coldfinger34723 жыл бұрын
There may be many better programmer than you, but I have not seen better teacher than you for sure. The way you teach in flow is soo dope. thank you so much.
@criminalcoder63074 жыл бұрын
I'm a fresher and I completed all the data structures playlist . Thanks
@priyanshigupta13593 жыл бұрын
apko kaise thanks bolo bhaiya ...aap itna acha padhate ho mujhse stack ke ques solve hone lge...thanks bhaiya
@bhavyamalviya83643 жыл бұрын
Thanks for taking time out from your schedule and sharing the knowledge with all of us
@neerajmahapatra52392 жыл бұрын
I just imagined the explanation just by hearing the problem statement hats off to you ..
@YashHalgaonkar3 жыл бұрын
Just watched the explanation of the question. Got the intuition and solved it on my own in less than 5 min. Amazing work @AdityaVerma!!
@milimishra64473 жыл бұрын
first time someone explained like this............great content..thanksssssssssssssss alot..u r amazingggggggggggggggggggggggggggggggg..
@vineetswami3762 жыл бұрын
Almost three year passes, but no one can make better content then you, you are such a genious.
@Gauravkumar-kc6xh2 жыл бұрын
Wanted all dsa by you bro. You just rock the dsa.
@ASHISHSINGH-gs3yt Жыл бұрын
Slight optimisation for time complexity Just store the index of the elements in the array and code as following : stack s; for(int i=0; i
@PritamKumar-mr5dv4 жыл бұрын
yes bhaiya zindagi me kohi batayga must phadtey ho app....huge support bhaiya.....
@parvahuja76189 ай бұрын
sir you are really the best teacher out there
@abhishekrattu2 жыл бұрын
The best person who is teaching in the BEST way! Very Very Helpful content :)
@ankursharma60843 жыл бұрын
Sucha a unique and beautiful way of teaching. You are really an awesome tutor. Yesterday i watched Coding Blocks video and today after watching your video i know that you are in a complete different level. And that also we get your outstanding content and experience for free. This is so thankful of you.
@b82tushar223 жыл бұрын
Kya beta, mjaa aa rha hai na!
@suvam2perfect4 жыл бұрын
If I got your series 3 years back perhaps I might not waste my b.tech years 🙌
@AnkushKumar-mk8ns3 жыл бұрын
Might...
@AshishPal-ki8tr3 жыл бұрын
maine khud se kar liyaa ye question ,What a feeling!! thanks @Aditya Verma
@bismeetsingh3524 жыл бұрын
Python Code: i=0 while i0 and stack[-1][1]0: difference=i-stack[-1][0] ans.append(difference) else: ans.append(i+1) stack.append((i,arr[i])) i+=1 print(ans)
@ay-tw4om Жыл бұрын
there is a leetcode editorial for this question which has O(1) amortized time complexity. Running a for loop for each call to next() is not needed. The key idea behind this approach is that the "answer" for a previous "price" can be directly added to the current answer, if current price is greater.
@nadeem29442 жыл бұрын
without using a pair in stack : #include vector findSpans(vector &price) { stack s ; int n = price.size() ; vector ans(n) ; for(int i = 0 ; i < n ; i++ ) { int curr = price[i] ; while( !s.empty() && price[s.top()]
@jayachandra6773 жыл бұрын
ese problems mere dimag ke upar se jata hai aur yeh tutorial tho aag laga di. thanks bhaiya :)
@GauravKumar-dw2ml3 жыл бұрын
I solved this question without using pair. As we can do price[s.top()] .Thanks @Aditya for such a strong foundation.
@varungupta50214 жыл бұрын
Bhaiya agar aapke jaisa professor college mai ho to sabka placement top product based company mai to hona hi hai. Appne question hi nai pura concept build kar diya Thanks for that!
@abhishek21162 жыл бұрын
explain in very simple manner , thanks sir, now i am able to move standard/tough or tricky method
@divya58084 жыл бұрын
Hattsss off to you sir!! You are just remarkable and phenomenon!! Please do post more videos like this,so that we can learn more from you!Thanks alot!
@danishakhtar26833 жыл бұрын
Man you are good the way teach you is just incredible,subscribed and share done . I already recommended your DP playlist to my juniors !! LOVE FROM NITW!!
@anshumansharma45803 жыл бұрын
I was able to do the answer myself after watching the problem statement part. Really these lectures are terrific. Instead of making an index vector, I simply made a pair with the answer that we have to return. So instead of traversing loop 2 times, we can do it in one traversal only. vector calculateSpan(int price[], int n) { // Your code here vector ans; stack S; for(int i=0;i
@anshulpandey65762 жыл бұрын
Same here bro . I too solved using same approach
@bhargavi3681 Жыл бұрын
Thank you so much for creating this videos. I have written the whole code by understanding the theory and with the help of previous videos. Great work sir. Thank you.🙏
@utsavseth6573 Жыл бұрын
Please please please Aditya bhai, Keep uploading videos. Your are one person who does not do any stupid things in video, explain properly, and it's all because of you that I am able to grasp the intuition, logic and flow correctly. Please dont stop making videos. Please make videos on graphs, trees, strings topics.
@PabitraPadhy3 жыл бұрын
I implemented this using a double stack method, but yours is cleaner. more importantly, it follows the same pattern as you said, so it's easier.
@tusharjangid24923 жыл бұрын
Great work man, was really helpful. One can see depth of your grasp on what you teach.
@Reels-fact-78 ай бұрын
thank you so much for easy explanation
@techlover7144 жыл бұрын
Border problems aside. But you Indians are exceptional programmers. Love Aditya Verma from Pakistan.
@RathourShubham4 жыл бұрын
No offence, but I have some questions. Why are you here? Do you even have codings there?
@techlover7144 жыл бұрын
@@RathourShubhamunlike India, only rapes are not present in Pakistan. But otherwise we have many things in common.
@LokeshSharmaCP9 ай бұрын
great bhai sach me zabardast... the flow.....😎
@priyasahu14394 жыл бұрын
I am really fan of your way of teaching and explaining each and every concept
@tanyacharanpahadi1584 жыл бұрын
Brooo you are so awesome. All the people watching this video you are really lucky to have your placements after jan 2020.
@LuciferScripts2 жыл бұрын
Great work. I saw two solution before this vdeo but no one explain as better as you. Thank You fron Pune Institute of Technology Pune, Maharashatra
@deepakjnvx10 ай бұрын
I dont think that there is any need of stack of pair, we can solve the question by just using stack of int as following.... vector calculateSpan(int price[], int n){ vector ans; stack st; for(int i=0;i
@rncsMahimaMahendru4 жыл бұрын
All your videos are amazing and super understandable please upload more soon!!
@shrutijain24262 жыл бұрын
Thanks @Aditya Verma. Your way of teaching is hands down the best. Even professors cannot teach in this way. Please make some videos on Queues and Linked Lists as well.
@deveshsingh72573 жыл бұрын
rather than storing values in stack we can store index ,therefore ,we don't need pair
@aisharawat91023 жыл бұрын
Bhaiya keep adding more videos ...I don't have words to explain how helpful your videos are..
@adityaagarwal6374 жыл бұрын
bhaiya ne bilkul jee wale tareke se pdaya hai , # mza aa gya :):):)
@shivamkasat63344 жыл бұрын
once I asked in my class group! how were you guys able to figure it out that this will be solved using stack ? And not a single person was able to answer it. but I know the answer now! Thanks!
@MandeepKumar-ue3zy4 жыл бұрын
😂
@vikaskumarnitrr2 жыл бұрын
i have been watching your videos for quite sometime now,and i am able to solve/code just by watching your explanation thanks bhaiya and your identification techniques is just mind blowing
@sumitsaurabh89433 жыл бұрын
Heartly, First time I subscribed and liked any playlist on youtuve . Really your explanation is intresting .thanks
@sauravkumarlal8964 жыл бұрын
Thank you for the great content bhaiya, waiting for more videos...😍😍
@KCODivyanshuKatyan3 жыл бұрын
never seen an explaination which is this good dammn awesome man hats off.....
@sulekhakumari-hs4gy4 жыл бұрын
Thanks bro. Effectivelity utilizing my corona time watching your videos.
@theunusual4566Ай бұрын
Thanks for explaining so wonderfully. The same code approach with slight modification : public static int[] calculateSpan(int price[], int n) { int[] result = new int[n]; Stack stack= new Stack(); for(int i=0; i
@jishulayek82523 жыл бұрын
U are an amazing teacher. Always like how to build the intuition part. Keep the good work going.
@skritichauhan4 жыл бұрын
your explainations are really amazing. Please make videos on bit manipulation questions too. With your explanations, students can easily master this topic as well
@ashvinimeshram52423 жыл бұрын
Your teaching style us just amazing
@DeepakThakur-gn7yl4 ай бұрын
Mind blowing explanation bahiyan❤
@AyushGupta-ux4gq11 ай бұрын
class Solution { public: //Function to calculate the span of stock’s price for all n days. vector calculateSpan(int arr[], int n) { // Your code here stack st; int count=1; vector ans; for(int i=0;i
@shreya-rs1fr4 жыл бұрын
we can make a single vector or array and directly push index of st.top() - I(index of element) instead of making two arrays and substracting them .
@fahadisrar21953 жыл бұрын
You made it look easy to identify the type. Great !!
@Aadyagupta56793 жыл бұрын
bhaiya i never think that, this question is total connect with NGL problem, the way you connect the problem is lit️. thank for providing such a great content!!
@disharastogi56092 жыл бұрын
amazing amazing explanation. You teach so well. Thanks a lot
@mohitmehta41434 жыл бұрын
Amazing explanations brother! Please make videos on the graph as well.
@dhruvarora2733 жыл бұрын
Sir , thanks for providing these all important questions at one place. Sir, please upload the queue and linked list questions also .
@paritoshdadhich29543 жыл бұрын
Thank you for such a great explanation. You are a gem. I tried to solve this question, tbh I mug up the solution but today I can code it with and can teach it to anyone. Thanks a ton bhaiya
@ayushthakur28963 жыл бұрын
Mugging up soln is also a way specially in backtracking problems .... what do u think
@pratikgoswami25693 жыл бұрын
waah bete moj kardi...tum toh bade heavy driver hoon
@Aditya_69965 ай бұрын
thanks bhaiya , amazing teaching skills !
@avinashkumarrao9728 Жыл бұрын
thanks bhaiya you are awesome the way you teach is very unique
@himanshugupta24072 жыл бұрын
og explaination big brother 🤩,looking forward to some amazing content from your side in future ,and the trick that u did with ur pen looks cool.
@ashwinikumargupta72002 жыл бұрын
class StockSpanner { public: vector arr; stack st; StockSpanner() { } int next(int price) { int day =1; while(!st.empty() && st.top().first
@unknownhacker8152 Жыл бұрын
Only index, we can put and while comparison we'll take array value at that index for java, bcoz there was no concept for pair, btw, thank you so much for great videos, i love it...
@devanshsrivastava31853 жыл бұрын
bhaiya please make more videos like this for different topics of data structures like trees, graphs etc. . LOve the way you teach thanks .
@samundarsingh9203 жыл бұрын
One thing i have to say that flipkart has one of the best teacher of DS and algo
@amanmaurya76465 ай бұрын
without making stack of pair of index and value we can make a simple stack storing only indices.. But it could be a bit confusing so you should use pair of stack only.
@manasvinsharma17404 жыл бұрын
I don't know why this video is not playing? I have checked all my connections and settings..
@shashanksarma40964 жыл бұрын
Bhai Mera bhi KZbin app pe nahi khulra tha chrome se khol le YT khul jayega
@manasvinsharma17404 жыл бұрын
@@shashanksarma4096 ok thnx buddy
@AmanVerma-cu3lp4 жыл бұрын
Same problem
@manasvinsharma17404 жыл бұрын
@@AmanVerma-cu3lp download and watch
@AmanVerma-cu3lp4 жыл бұрын
@@manasvinsharma1740 I would rather prefer @Shashank Sharma's solution.
@abhishekbabbar92344 жыл бұрын
best explanation i've ever seen for this problem... hats off brother... logic can be simplified to this also....- // java //pair is my class having 'val' ans 'ind' as two integer variables Stack st=new Stack(); int ans[]=new int[n]; for(int i=0;i
@akhilkumarsingh50414 жыл бұрын
can you give the whole code in java
@eklavyaprasad50093 жыл бұрын
Please share the pair class code
@ayush75182 жыл бұрын
share the whole code please.
@LokeshSharma-hm5jz Жыл бұрын
how easy this question is now. Thank you
@DroidHolicOfficial2 жыл бұрын
Since we are dealing with indexes here. WE can just put indexes in the stack instead of the pair. calculateSpan(price, n) { let stack = [0]; let output = new Array(n); output[0] = 1; for(let i = 1; i < n; i++){ while(stack.length > 0){ let topIndex = stack[stack.length - 1]; let top = price[topIndex]; if(top > price[i]){ stack.push(i); output[i] = i - topIndex; break; } else{ stack.pop(); } } if(stack.length === 0){ output[i] = i + 1; stack.push(i) } } return output; }
@vemulaakash82124 жыл бұрын
Thanks a lot bhayya for all that great and clear explanation .
@AyushYadav-zn8fc Жыл бұрын
you're a great teacher. you should make more videos on other topics
@harshita6683 Жыл бұрын
Thankyou i was able to solve such questions finally!
@lakshaybansal95972 жыл бұрын
Plz continue upload the video this is very helpful
@SahilSharma-vl9rk3 жыл бұрын
1 video dekhi bass nearest greater to right aage ke foundation waale khud se ban gye + stock span problem bhi khud se ban gaya what a great content
@raisanjeeb422 жыл бұрын
Solved without looking at the explanation. The concept explained in 1st question is enough to tackle these question. Thank You for ur teaching🙌🙌❤
@nik-r2h4 ай бұрын
great explanation!! btw, we can also do it without creating pair. vector calculateSpan(int arr[], int n) { vector ans; stack s; for(int i=0;i0 && arr[i]>=arr[s.top()]){ s.pop(); } if(s.size()==0)ans.push_back(-1); else ans.push_back(s.top()); s.push(i); } for(int i=0;i
@minkiaggarwall55294 жыл бұрын
bhai tumne ds padi kese thoda share kardo bohat achai knowlrdge hai. sources and how to study..........best video ever seen
@pranaypiyush50324 жыл бұрын
Best explainations I ever received
@kuldipchoudhary58054 жыл бұрын
Great job man Amazing vedios ..Keep up the good work
@prakharagarwal49334 жыл бұрын
thank bhaiya... your videos are very well serving it purpose