Тёмный

Remove K Digits | Leetcode 402 | Day-18 | Stack 

Ayushi Sharma
Подписаться 45 тыс.
Просмотров 8 тыс.
50% 1

Опубликовано:

 

17 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 74   
@akashjha822
@akashjha822 2 года назад
Those who is getting Memory Limit Exceeded just do ans += st.top(); And reverse the ans string after execution of the loop. reverse(ans.begin(),ans.end()) By the way Awesome Explanation as always.
@ashady8
@ashady8 2 года назад
Hi, thanks. It worked for me. However, can you please tell me why it works?
@akashjha822
@akashjha822 2 года назад
@@ashady8 Ya, when you do ans = st.top() + ans it creates copy of both st.top() and ans, since st.top() is a character, so, it does not create much effect on memory but ans is string so when ans is very large then it gives you Memory Limit Exceeded but when you do ans += st.top() it creates copy of only st.top() so we reduced memory usage but it is in reverse form so you have to reverse the array after the loop.
@ashady8
@ashady8 2 года назад
@@akashjha822 Thanks a lot
@abul_khasim1730
@abul_khasim1730 Год назад
@@akashjha822 thanks man!
@lakeshkumar1252
@lakeshkumar1252 9 месяцев назад
thanks
@a.gcrazy555
@a.gcrazy555 3 месяца назад
I have literally watched 4-5 videos before coming to this nobody can explain this question with this much simplicity and clarity . Hatts Off to you !!
@AyushiSharmaDSA
@AyushiSharmaDSA 3 месяца назад
Thank you so much ❤️😊🤝🏻
@nitinramamoorthy8713
@nitinramamoorthy8713 2 года назад
Dear Ayushi, While implementing your logic, It is showing memory limit exceeded while submitting, Kindly look into it. I think the while loop check for stack not empty && top element > num[i] && k>0 is causing this issue!
@vaidanshkukreja8970
@vaidanshkukreja8970 2 года назад
Amazing video! I can say this explanation is one of the best of yours 🤩🤩 Please explain like this only from now onwards and one more suggestion please don't care about length of video u just make the tutorial like this coz explanation like this is much needed and which is missing On RU-vid
@AyushiSharmaDSA
@AyushiSharmaDSA 2 года назад
Thank you so much Vaidansh :) means a lot
@VY-zt3ph
@VY-zt3ph 2 года назад
@@AyushiSharmaDSA yeah you should not care about the length of the video. Cover as much as you can.
@AyushiSharmaDSA
@AyushiSharmaDSA 2 года назад
@@VY-zt3ph sure 😄
@apoorvmittal2473
@apoorvmittal2473 9 месяцев назад
THIS SOLUTION IS GIVING MEMORY LIMIT EXCEED ON 42nd TESTCASE to avoid that we have to declare an empty string and then use push_back operation to fill it and then use reverse // this problem wasted 30 min , please correct your code
@rajdave7357
@rajdave7357 2 года назад
Great Intro. Great Explanation. Great Ending. Thanks for helping.
@AyushiSharmaDSA
@AyushiSharmaDSA 2 года назад
Thank you so much Raj for always supporting :)
@yashhokte1020
@yashhokte1020 Год назад
You have my respect mam !! It's the great intuitive solution I have ever found. Thank you so much for explaining it in a concise and easy way.
@AyushiSharmaDSA
@AyushiSharmaDSA 5 месяцев назад
thank you Yash, glad it was helpful :)
@CNILOYBARUA
@CNILOYBARUA Год назад
Best video mam, Thanks for the quality content,love from Bangladesh 🇧🇩🇧🇩🇧🇩🇧🇩We need more mam like this
@AyushiSharmaDSA
@AyushiSharmaDSA Год назад
Thanks a lot Niloy , huge love ❤️😊
@shwetaj8189
@shwetaj8189 Год назад
All my doubts are cleared. This is the best video on the youtube!
@vikaas.sharma
@vikaas.sharma Год назад
ony four test case passed after using your approach 🙃
@codersworld2846
@codersworld2846 2 года назад
Best explanation
@shashanksharma136
@shashanksharma136 Год назад
nicely explained mam.
@UdayYadav-jb5og
@UdayYadav-jb5og Месяц назад
nice explanation
@AyushiSharmaDSA
@AyushiSharmaDSA Месяц назад
Thanks :)
@VishalYadav-p7k
@VishalYadav-p7k Год назад
All small details are explained in an easy way. Nice explanation. Stay happy ☺
@AyushiSharmaDSA
@AyushiSharmaDSA Год назад
Thanks Vishal, glad it was helpful 😊😊
@VY-zt3ph
@VY-zt3ph 2 года назад
Although i didn't see your entire video because i got the hint from the title. but i checked your description box and you really have amazing playlist.
@AyushiSharmaDSA
@AyushiSharmaDSA 2 года назад
Thank you😊
@desihiphop4998
@desihiphop4998 2 года назад
Bhut bdia di 🔥🔥
@AyushiSharmaDSA
@AyushiSharmaDSA 2 года назад
Thank you :) glad it was helpful
@sayantaniguha8519
@sayantaniguha8519 2 года назад
Can we use same logic to return largest possible integer ?
@Ram_sujan_rajak
@Ram_sujan_rajak 10 месяцев назад
grate work🔥🔥
@AyushiSharmaDSA
@AyushiSharmaDSA 9 месяцев назад
thank you :)
@iiiii3536
@iiiii3536 2 года назад
Thank you for the approach di
@AyushiSharmaDSA
@AyushiSharmaDSA 2 года назад
Welcome Ishann, glad it was helpful :)
@ABHISHEKKUMAR-wc9ke
@ABHISHEKKUMAR-wc9ke 2 года назад
best explaination
@AyushiSharmaDSA
@AyushiSharmaDSA 2 года назад
Thank you Abhishek :)
@jasper5016
@jasper5016 2 года назад
Thanks for this amazing video.
@AyushiSharmaDSA
@AyushiSharmaDSA 2 года назад
Welcome Jasper :)
@juhisingh4509
@juhisingh4509 2 года назад
Very intuitive explanation Ayushi👏
@AyushiSharmaDSA
@AyushiSharmaDSA 2 года назад
Thank you Juhi, glad it was helpful :)
@amitkumar-qc2yq
@amitkumar-qc2yq 2 года назад
Literally 🔥 explanation
@AyushiSharmaDSA
@AyushiSharmaDSA 2 года назад
Thank you so much Amit :)
@noobbot4654
@noobbot4654 2 года назад
was just waiting for this video Thank you!!
@AyushiSharmaDSA
@AyushiSharmaDSA 2 года назад
Welcome NoobBot :) Thanks :)
@anishkumargiri9490
@anishkumargiri9490 Год назад
thank you so much ❤
@sayantaniguha8519
@sayantaniguha8519 2 года назад
can u explain the reason for that : *while(k>0)* loop ?
@king-ij1ly
@king-ij1ly 2 года назад
superb explanation didi
@AyushiSharmaDSA
@AyushiSharmaDSA 2 года назад
Thanks 🤗
@nimeshsingh6229
@nimeshsingh6229 2 года назад
Was waiting for this 😅
@AyushiSharmaDSA
@AyushiSharmaDSA 2 года назад
Thank you Nimesh, your support keeps me motivated :)
@DhananjayKumar-vn5tc
@DhananjayKumar-vn5tc 2 года назад
heyy, u are doing great for community can u make video on leetcode 910 .
@AyushiSharmaDSA
@AyushiSharmaDSA 2 года назад
Thank you Dhananjay :) Sure, I'll make a video on it :)
@mansigoyal4796
@mansigoyal4796 2 года назад
Thankyou di :)
@AyushiSharmaDSA
@AyushiSharmaDSA 2 года назад
Welcome Mansi, glad it was helpful :)
@anshulsoni653
@anshulsoni653 Год назад
everything is fine, just get a good mic, or audio mixer the overall volume is too low
@ankit_1012
@ankit_1012 Год назад
I guess we dont even need a stack this can be done in place that will be optimal string removeKdigits(std::string num, int k) { int n = num.length(); int top = -1; for (int i = 0; i < n; i++) { while (k > 0 && top >= 0 && num[i] < num[top]) { top--; k--; } num[++top] = num[i]; } while (k > 0 && top >= 0) { top--; k--; } int leadingZeros = 0; while (leadingZeros
@anandprakashchaudhary2358
@anandprakashchaudhary2358 2 года назад
Nice
@AyushiSharmaDSA
@AyushiSharmaDSA 2 года назад
Thank you Anand :)
@shreshthajitdas1388
@shreshthajitdas1388 2 года назад
You are too good apu....
@AyushiSharmaDSA
@AyushiSharmaDSA 2 года назад
Thank you Shreshthajit. Means a lot :)
@shivamdubey2418
@shivamdubey2418 8 месяцев назад
In which company do you work
@priyamagarwal7754
@priyamagarwal7754 2 года назад
Ayushi Your code is giving TLE.
@abhishekanand9430
@abhishekanand9430 Год назад
sister your sound is too much low in this video
@pankhurigupta8623
@pankhurigupta8623 Год назад
voice volume is too low
@jayeshnayee6735
@jayeshnayee6735 Год назад
Thoda voice loud karo
@shadowaj9278
@shadowaj9278 2 года назад
I was tweaking string instead of using stack 😓.
@AyushiSharmaDSA
@AyushiSharmaDSA 2 года назад
Like using extra string for storing??
@shadowaj9278
@shadowaj9278 2 года назад
@@AyushiSharmaDSA yes mam
@samarthdarkbeast9279
@samarthdarkbeast9279 7 месяцев назад
please speak louder ...else all your videos are useless
Далее
Remove K digits | Build lowest number | Leetcode #402
15:30
Decode String 🔥 | Leetcode 394 | Stack
17:33
Просмотров 17 тыс.
Não sabe esconder Comida
00:20
Просмотров 4,5 млн
Snapdragon Dev Kit CANCELLED
5:31
Просмотров 10 тыс.
Sum of Subarray Minimums - Leetcode 907 - Python
18:51
L14. Remove K Digits | Stack and Queue Playlist
15:29
Remove K Digits - Leetcode 402 - Python
14:36
Просмотров 62 тыс.
3 Types of Algorithms Every Programmer Needs to Know
13:12
Não sabe esconder Comida
00:20
Просмотров 4,5 млн