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

  Рет қаралды 13,673

Nikhil Lohia

Nikhil Lohia

Күн бұрын

Пікірлер: 44
@prashantyallatti7780
@prashantyallatti7780 Жыл бұрын
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 Жыл бұрын
just remove the equal to sign from the while loop condition. Thats it :)
@nikoo28
@nikoo28 Жыл бұрын
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 жыл бұрын
Please keep uploading the videos. I get the best Explaination/ solutions / answers on this channel. 👍🏻
@rajenshrestha8795
@rajenshrestha8795 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 жыл бұрын
Please upload more leetcode problems! Your explanation is really great :)
@rachitchaddha999
@rachitchaddha999 Жыл бұрын
ur way of explaining question is really nice and interesting
@japneetkaur7095
@japneetkaur7095 Жыл бұрын
amazing explanation...thank you for this!!
@iii7317
@iii7317 Жыл бұрын
You providing more better than UDEMY . Concept 100% ... UPLOAD = RESPECT
@nikoo28
@nikoo28 Жыл бұрын
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 жыл бұрын
Great Explanation
@SwadeepChavan
@SwadeepChavan Ай бұрын
thank your nikhil great explanation, please make video on sliding window maximum
@rohitsaka
@rohitsaka 3 жыл бұрын
Thank you so much brother .. means a lot ! 😊
@nikoo28
@nikoo28 3 жыл бұрын
Always welcome mate. Fans like you are always a support 😄
@Jaylight977
@Jaylight977 Жыл бұрын
@@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 жыл бұрын
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
@RoshanSingh-kj4fy
@RoshanSingh-kj4fy 17 күн бұрын
tq
@Priyansh_Garg15
@Priyansh_Garg15 6 ай бұрын
thanku
@pratibhajaiswal9665
@pratibhajaiswal9665 3 жыл бұрын
What is the time complexity of the efficient solution?
@nikoo28
@nikoo28 3 жыл бұрын
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 5 күн бұрын
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 жыл бұрын
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
Online Stock Span - Leetcode 901 - Python
15:19
NeetCode
Рет қаралды 35 М.
UFC 310 : Рахмонов VS Мачадо Гэрри
05:00
Setanta Sports UFC
Рет қаралды 1,2 МЛН
To Brawl AND BEYOND!
00:51
Brawl Stars
Рет қаралды 17 МЛН
Stock span problem
14:39
Techdose
Рет қаралды 50 М.
L15. Stock Span Problem | Stack and Queue Playlist
19:21
take U forward
Рет қаралды 38 М.
How I would learn Leetcode if I could start over
18:03
NeetCodeIO
Рет қаралды 836 М.
6 Stock Span Problem
28:02
Aditya Verma
Рет қаралды 224 М.
How to Start LeetCode from ZERO in 2025
11:31
Ashish Pratap Singh
Рет қаралды 145 М.