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

Поділитися
Вставка
  • Опубліковано 22 січ 2025

КОМЕНТАРІ • 42

  • @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 10 місяців тому

      acually the

    • @VANAPARTHIBULLISIVABCE
      @VANAPARTHIBULLISIVABCE 9 місяців тому

      @@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  10 місяців тому

      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

  • @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.

  • @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 ?

  • @NikolayMishin
    @NikolayMishin Рік тому

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

  • @kunalmalpure3409
    @kunalmalpure3409 2 роки тому +1

    Thanks great video

  • @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 :)

  • @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

  • @anubhv0001
    @anubhv0001 Рік тому

    op solution bhaii!

  • @MyselfTheodore
    @MyselfTheodore Рік тому

    Thank you

  • @RoshanSingh-kj4fy
    @RoshanSingh-kj4fy 4 дні тому

    tq

  • @Priyansh_Garg15
    @Priyansh_Garg15 6 місяців тому

    thanku

  • @sksabir8063
    @sksabir8063 6 місяців тому

    wow😊

  • @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