Stock Span Problem (Leetcode 901) | Online Stock Span | Simplified w/ animations | Study Algorithms

Поделиться
HTML-код
  • Опубликовано: 5 фев 2025

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

  • @prashantyallatti7780
    @prashantyallatti7780 Год назад +2

    The above solution does not work for testcase [10 ,10, 10 10] expected result would be [1,1,1,1] but above solution will give [1,2,3,4]..and it is wrong..

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

      just remove the equal to sign from the while loop condition. Thats it :)

    • @nikoo28
      @nikoo28  Год назад +4

      Thanks for pointing this out. I have fixed the solution on the Github link, also added your particular test case. Thanks for the contribution. :)

    • @ajay.2461
      @ajay.2461 11 месяцев назад

      acually the

    • @VANAPARTHIBULLISIVABCE
      @VANAPARTHIBULLISIVABCE 10 месяцев назад

      @@nikoo28 Sir, I think your code is correct .There is no need to remove equal sign because we consider the values which are equal or less than the current value. If we have to choose the values that are strictly less than ,then we need to remove .so for 10 10 10 10 the output will be 1 2 3 4 only.

  • @shraddhajain8935
    @shraddhajain8935 3 года назад +5

    Please keep uploading the videos. I get the best Explaination/ solutions / answers on this channel. 👍🏻

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

    Wow, I finally got the idea after watching your explanation, thank you so much!

  • @monismomin6759
    @monismomin6759 11 месяцев назад

    Thank you so much!! I was searching for the question, but I was not able to understand the intuition from others' videos. I got intuition because of you!!

    • @nikoo28
      @nikoo28  11 месяцев назад

      that is so great to hear

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

    Please upload more leetcode problems! Your explanation is really great :)

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

    ur way of explaining question is really nice and interesting

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

    amazing explanation...thank you for this!!

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

    You providing more better than UDEMY . Concept 100% ... UPLOAD = RESPECT

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

      Please share these videos as much as you can with your peers. It keeps me motivated and youtube would also promote them automatically then.

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

    Great Explanation

  • @SwadeepChavan
    @SwadeepChavan Месяц назад

    thank your nikhil great explanation, please make video on sliding window maximum

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

    Thank you so much brother .. means a lot ! 😊

    • @nikoo28
      @nikoo28  3 года назад +1

      Always welcome mate. Fans like you are always a support 😄

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

      @@nikoo28 bhaiya really ,your explanation skill is next level ,love u . one day i wanna a meet u 😆😆

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

      @@Jaylight977 one day... 😄

  • @GayathriKondepudi-m5o
    @GayathriKondepudi-m5o Год назад

    Excellent explanation sir... keep uploading videos....

    • @nikoo28
      @nikoo28  11 месяцев назад

      Keep watching

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

    Thanks great video

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

    op solution bhaii!

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

    красавчик, отлично объясняешь!

  • @vilakshan.s
    @vilakshan.s 9 месяцев назад

    Understood the solution but one doubt:- How the time complexity is O(n). Worst case scenario is like for ith element you might have to iterate over and remove all elements of the stack till last element. That way it will be O(n^2). One possible example can be like if input array is ascending order. If this understanding is correct, then is there a diff between brute force and stack based solution ?

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

    Being experienced, you should have handled the case for equal values in array too. Your solution is INCORRECT. Remove the equal to sign and you're good to go.

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

      Apologies for the miss, I have fixed it on the github link.

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

    Thank you

  • @Priyansh_Garg15
    @Priyansh_Garg15 6 месяцев назад

    thanku

  • @RoshanSingh-kj4fy
    @RoshanSingh-kj4fy 17 дней назад

    tq

  • @pratibhajaiswal9665
    @pratibhajaiswal9665 3 года назад +1

    What is the time complexity of the efficient solution?

    • @nikoo28
      @nikoo28  3 года назад +1

      That would be O(n) as you are only traversing the array once.

    • @pratibhajaiswal9665
      @pratibhajaiswal9665 3 года назад

      @@nikoo28 Thanks :)

  • @sksabir8063
    @sksabir8063 6 месяцев назад

    wow😊

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

    Where can i get a text based version of this video explanation ?

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

      I haven't created it yet.

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

      @@nikoo28 A small request😊
      If it possible to create the same
      Also, for the recent I don't see a text based version
      If possible can you create for them too

  • @AmitKumar-cp1oz
    @AmitKumar-cp1oz 6 дней назад

    but the leetcode have different format for the solution.

    • @nikoo28
      @nikoo28  5 дней назад

      check out the code on github (link in description), it has the full code with the same leetcode format. The video goes over the core logic.

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

    we want a faster solution , time limit is exceeding .

    • @nikoo28
      @nikoo28  2 года назад

      Check the link in the description…it has the complete solution with all test cases

    • @vaibhavsharma7630
      @vaibhavsharma7630 2 года назад

      My mistake , this is the fastest way . They have some compiler issue

  • @islamansari2212
    @islamansari2212 2 года назад

    Plll