Тёмный

Maximum Element in Stack - HackerRank Data Structures Solutions in C/C++ 

nexTRIE
Подписаться 6 тыс.
Просмотров 7 тыс.
50% 1

HackerRank solution for Maximum Element in Stack in C++. Here, I'm using two stacks, one of which tracks only maximum elements. Remember that a C++ STL Stack is a LIFO data structure, on which we can only push and extract elements from a single end (the top).
All HackerRank solutions on GitHub (please leave a star): github.com/Isa...
Maximum Element HackerRanK problem: www.hackerrank...

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

 

11 сен 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 20   
@prashant7622
@prashant7622 3 года назад
its very good.you can add some more things like what does cin.ignore do . i mean practically how does it contained in buffer and then had a effect on the next input.since i was searching for it . so i told you . it was a good explanation keep it up;
@nextrie
@nextrie 3 года назад
Hey Prashant, sure! I actually explained what cin.ignore() does in a previous video, I think. But your feedback is welcome. I'll make sure to provide as much detail as I can.
@pavankarthiknvs934
@pavankarthiknvs934 3 года назад
Nice explanation sir.
@nextrie
@nextrie 3 года назад
Thanks so much, Pavan!
@gawarivivek
@gawarivivek 3 года назад
It helped!! Thanks a lot, Sir!!
@nextrie
@nextrie 3 года назад
That's amazing, Vivek! Are you practicing for technical job interviews?
@gawarivivek
@gawarivivek 3 года назад
​@@nextrie : Not actually!!
@nextrie
@nextrie 3 года назад
@@gawarivivek hehe, alright. Well, happy coding!
@gawarivivek
@gawarivivek 3 года назад
@@nextrie : Actually yes, I'm kind of!! I am sure your videos are gonna help me a lot.. :) Would like to connect with you.. On any platform like LinkedIn, Discord, etc.
@shivasai7707
@shivasai7707 2 года назад
for case 3 what do query value contain its giving segmentation fault
@moash6379
@moash6379 2 года назад
thanks
@ratneshmishra2802
@ratneshmishra2802 3 года назад
I tried the above solution but had a segmentation fault :-(
@nextrie
@nextrie 3 года назад
Hi Ratnesh, I just tried running my solution again, and I did not get any segmentation fault. I was able to pass all 28 test cases. Please review your code to ensure that you've declared all your variables and containers, and that you're not accessing any invalid data. You may also get an error if you forget the "break" statements in your switch statement.
@ratneshmishra2802
@ratneshmishra2802 3 года назад
@@nextrie OKK bro thnq :-)
@the_shridhar
@the_shridhar 3 года назад
You probably have forgot to add break statement or you have declared s.pop() in if condition, i was facing same error!
@nextrie
@nextrie 3 года назад
So does it work as expected now?
@the_shridhar
@the_shridhar 3 года назад
@@nextrie yes yes all cases are correct! You are a great teacher by the way!
@manup7636
@manup7636 4 года назад
hey bro
@nextrie
@nextrie 4 года назад
What's up, Manu?