Stock span problem

แชร์
ฝัง
  • เผยแพร่เมื่อ 24 ธ.ค. 2024

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

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

    Bro, you literally must have spend a lot of time and efforts for sure because you explain such complex problems with ease ! that even experienced professional tutors aren't able to. Really appreciate your hardwork and contribution. Thanks buddy :)

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

    I was finding the correct explanation from long time. My search ends here and you found a new subscriber. I will keep referring your video. Appreciate your effort you kept in this video, and thank you for helping me out! 🙂

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

    If anyone did not understand why the time was O(2N), it is because, for each element in the array, we at max do only 2 operations: 1. we push it to stack 2. We pop it from the stack. The whole algorithm just does this. So the worst case will be all the elements are pushed and also popped while running the algo. Hence O(2N)

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

    everyone was complicating it ... I found relief in your solution ... the code at side really helped to visualise !

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

    sir, thank you very much from bottom of my heart. you are putting a lot of effort. your video helps me a lot.

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

      I am glad that students feel the way you do :) This is my motivation

  • @karanroy-vr1wn
    @karanroy-vr1wn 5 ปีที่แล้ว +1

    yesterday night i read the book ....i didn't understand ...but after watching your video i got the clear cut idea ..

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

    Thank you very sir.I was searching on youtube regarding this problem watched 2 other videos and stopped here. You made my understanding clear.

  • @KRajesh-ej7dy
    @KRajesh-ej7dy ปีที่แล้ว +1

    after seeing many vidoes i got good clarity in this thank you bro

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

    Best video for algo ..
    Thanks sir.😊

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

    This video explained the problem very well! Thanks a lot sir

  • @digitechtalks4167
    @digitechtalks4167 2 ปีที่แล้ว

    only this video gives me a clear approach!!

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

    Have you uploaded video on redundant bracket?..I am not getting it

  • @aryan7069_
    @aryan7069_ 2 ปีที่แล้ว

    Where u implemented queue and stack for competitive programming. Solution.... coz theres no queue stack in STL

  • @anand__346
    @anand__346 2 ปีที่แล้ว

    awesome and mind blowing explanation bro , thank u very much 🔥🔥🔥

  • @vibes.productive
    @vibes.productive 2 ปีที่แล้ว +1

    Thank your for your clear explanation sir....helped a lot!

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

    Your Explanation technique is awesome. If possible please make more videos related to hashing,backtracking and Strings.

  • @GhostRider....
    @GhostRider.... 2 ปีที่แล้ว

    Nice explanation sir

  • @balramchaudhary6449
    @balramchaudhary6449 3 ปีที่แล้ว

    very informative video. Thanks a lot.

  • @mohitdeo3648
    @mohitdeo3648 3 ปีที่แล้ว

    can your soln work for input:13,15,12,14,16,8,6,4,10,30

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

    U teaches nice and u do a lot of efforts

    • @techdose4u
      @techdose4u  5 ปีที่แล้ว

      Yea it takes a lot of effort to make even a small video :) I am glad you all love it.

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

      @@techdose4u I would suggest you to make dedicated videos on DP and graphs including medium level questions not just easy one to attract regular views and with easy or general questions u will not attract students for long but with dedicated videos students follows regularly

    • @techdose4u
      @techdose4u  5 ปีที่แล้ว

      Yes true. It's all about time. As soon as i get time, i make some videos. Will continue with graph soon. I was thinking the same as you suggested.

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

    Thanks for providing these vdos..

  • @abhiram3275
    @abhiram3275 3 ปีที่แล้ว

    excellent approach sir.loved it

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

    Hi. I don't understand the maximum profile sales wine problem (DP approach). can you make a video on it?

    • @techdose4u
      @techdose4u  5 ปีที่แล้ว

      Yea sure.....will make this week :) Thanks for suggesting. If you have a link then do share.

    • @techdose4u
      @techdose4u  5 ปีที่แล้ว

      Can you provide a link to the problem. I found wine selling with max profit using DP. Is this the one?

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

      @@techdose4u Thank you.
      here is the link,
      www.geeksforgeeks.org/maximum-profit-sale-wines/

  • @sureshgarine
    @sureshgarine 3 ปีที่แล้ว

    nice explanation. how did u get a thought that stack is a better data structure for solving this problem? can anyone explain

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

    Thanks Surya for your wonderful explanation!
    I have a quick question here. How the stack traversal is different brute force traversal?
    I guess both will take same time...isn't it? For example in brute force technique, we started at 6th Index and traversed all the way till first element. And we did the same thing in stack as well.

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

      here we are removing elements that are smaller than given index i, and after that we are pushing i in the stack, so if we go to next index and if arr[i+1]> arr[i], then we will be sure that the elements that we have removed in the previous step are less that arr[i+1], so we don't have traverse that elements again as they are already removed.

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

    so poping element will not make the algo O(N2). I just do not know how come this is O(N)

    • @techdose4u
      @techdose4u  3 ปีที่แล้ว

      That's because an element can be popped only once. So max time for popping is also O(N).

    • @rahulshrivastava3040
      @rahulshrivastava3040 3 ปีที่แล้ว

      @@techdose4u not quite right. you have a while loop which will keep popping till you see a larger element.

    • @techdose4u
      @techdose4u  3 ปีที่แล้ว

      While loop doesn't make the time complexity O(N2). The inner while loop will pop a maximum of N elements combining all the outer loops. Dry to dry run by using any example. You can go to 2N but not N^2.

  • @kushalhu7189
    @kushalhu7189 3 ปีที่แล้ว

    Great Explanation

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

    What is the difference between this problem and online stock problem?

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

      All values are known already here. But online means you see an element at a time without knowing about future :)

  • @shreyajoshi5148
    @shreyajoshi5148 3 ปีที่แล้ว

    U explain so well 😇

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

    marvelous expalantoin sir,thanks a lot ....

  • @ShivamSingh-me1nb
    @ShivamSingh-me1nb 4 ปีที่แล้ว +1

    Brilliant explanation

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

    Can you just use the previous calculations, like "if previous element is less than the current one, look to the left of the lower element's span"?
    This way you'll reuse the previous calculations and don't need the stack.

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

    Nice Explanation thanks for the efforts you put to make awsome videos that help lot of people :)

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

    Truly appreciable... Very nicely explained. I have subscribed you. Thanks for this video.

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

    Nice explanation 👌👌👌 bro

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

    Hi great video!
    What software do you use?

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

    Plz give the code implementation also in c

  • @Legendary-Akshit
    @Legendary-Akshit 4 ปีที่แล้ว +2

    Excellent explanation. Video highly recommended.

  • @Inndjkaawed2922
    @Inndjkaawed2922 2 ปีที่แล้ว

    Nearest greater integer to the left..that's the concept

  • @prasad.patil12
    @prasad.patil12 4 ปีที่แล้ว +2

    It takes lots of efforts to make such videos and explain in simplest possible way
    This is priceless 👍

    • @techdose4u
      @techdose4u  4 ปีที่แล้ว

      Yea it does. Thanks :)

    • @jagankumarpatra
      @jagankumarpatra 2 ปีที่แล้ว

      @@techdose4u same code is there in gfg article not more

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

    Thankyou so much, sir!!!

  • @ahmedmohammedshahid1007
    @ahmedmohammedshahid1007 2 ปีที่แล้ว

    Amazing

  • @yatri6329
    @yatri6329 3 ปีที่แล้ว

    what will the Answer if [100,80,60,70,65,75,85]

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

    Thank you sir for such a nice explanation.
    I didn’t understand worst time complexity how it come out to be O(N).
    I believe that it’s O(N^2).
    Sir could you please help me with time complexity?

    • @kapilkungwani8025
      @kapilkungwani8025 4 ปีที่แล้ว

      Traversal of array is done one time, so time complexity is O(N)

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

    Nice one yo

  • @BECSAQUIB
    @BECSAQUIB 3 ปีที่แล้ว

    Jazakallah khair

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

    Thank you!

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

    Thank you sir 🤗

  • @karanroy-vr1wn
    @karanroy-vr1wn 5 ปีที่แล้ว +2

    sir, plz make video on dynamic programming ......as it is asked more in interview.....make a playlist of DP and upload 2-3 video daily....plz .....i have very less time to prepare for job.

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

      When is your interview?

    • @karanroy-vr1wn
      @karanroy-vr1wn 5 ปีที่แล้ว

      @@techdose4u within 20 days

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

      I will keep uploading but the thing is that i make videos whenever i get time. I upload the important questions for interview itself. If you need any help for interview then let me know.

    • @karanroy-vr1wn
      @karanroy-vr1wn 5 ปีที่แล้ว +1

      @@techdose4u ok ,sir

  • @RaushanKumar-co3wj
    @RaushanKumar-co3wj 4 ปีที่แล้ว +1

    awesome

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

    before moving to next day i, you forget to tell the part of pushing back the popped elements from another stack till i-1 days.

    • @techdose4u
      @techdose4u  4 ปีที่แล้ว

      May have missed.....😅

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

    Thanks sir

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

    nice

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

    vwery nicely ex[lained

  • @shigo6350
    @shigo6350 4 ปีที่แล้ว

    Thank you so much....

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

    I want to donate for your channel.

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

      Consider your support as a donation :)

  • @gtbaba123
    @gtbaba123 2 ปีที่แล้ว

    Ty brother

  • @karanroy-vr1wn
    @karanroy-vr1wn 5 ปีที่แล้ว +1

    sir, plz make video on dynamic programming ......as it is asked more in interview.....make a playlist of DP and upload 2-3 video daily....plz .....i have very less time to prepare for job.

    • @techdose4u
      @techdose4u  5 ปีที่แล้ว

      When is your interview?

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

      Have you paid me ? that he'll fully dedicate his time to upload 2-3 videos specifically on DP for you because your interview is coming? Morons -_-