Design a Stack that supports getMin() in O(1) time and O(1) extra space | Babbar DSA Sheet | Amazon🔥
Vložit
- čas přidán 22. 07. 2021
- #stacks #queues #stackqueue #competitiveprogramming #coding #dsa
Hey, Guys in this video I have explained how we can solve the problem 'Design a Stack that supports getMin() in O(1) time and O(1) extra space'.
Join our Telegram Channel for more Information
🔰 Telegram Channel Link = t.me/CodeLibrary1
🔰 Telegram Discussion Group Link = t.me/CodeLibraryDiscussion
--------------------------------------------------------------------------------
Unacademy Links--
Use my code "YOGESH" to access all FREE classes and get a 10% Discount on Paid Courses.
Exclusive 5- Month Learning Track for College/ Off-Campus Placements: bit.ly/3B5Rczq
6-Week Mastercourse on Advanced Programming Topics: bit.ly/3kmF1In
(Java) Complete Course on Programming for Beginners: bit.ly/2UOBbgq
OS, DBMS & Networking Mastercourse: bit.ly/3AYscKi
--------------------------------------------------------------------------------
🔰 Array Playlist = • Love Babbar DSA 450 Qu...
🔰 String Playlist = • Love Babbar DSA 450 Qu...
🔰 Searching and Sorting Playlist = • Love Babbar DSA 450 Qu...
🔰 Binary Tree Playlist = • Love Babbar DSA 450 Qu...
🔰 Linked List Playlist = • Love Babbar DSA 450 Qu...
🔰 Graph Playlist = • Love Babbar DSA 450 Qu...
🔰 Dynamic Programming Playlist = • Love Babbar DSA 450 Qu...
🔰 Informative Videos = • Informative Videos
🔰 Love Babbar DSA Sheet: drive.google.com/file/d/1FMdN...
Follow us on Instagram:
🔰 Shailesh Yogendra : / shaileshyogendra
🔰 Yogesh Yogendra : / i_am_yogesh_here
Follow us on LinkedIn:
🔰 Yogesh Yogendra : / yogesh-yogendra-26bbb518a
🔰 Shailesh Yogendra : / shailesh-yogendra-8b13...
Hope you like it. Comment if you have any doubt
LIKE | SHARE | SUBSCRIBE
Waah bhai...Kahin samajh nahi aa rha tha...bss tera hi samajh aaya...
Well done bro...Great Explanation
Thanks very nicely explained
Thank you! Very well Explained💯
Great video.Thanks for sharing.👍👍
Thanks for the explanation.
quite good explanation......
Nice Explanation🤩
good video loigc ,same but instead of 2x-m if its confusing : simple logic is whenever you find a minimum element then store into stack as *previousminimum element
MY CODE FOR LEETOCDE IN C++:
class MinStack {
public:
stackst;
int mini=-1;
MinStack() {
}
void push(int val) {
if(st.size()==0)
{
st.push(to_string(val));
mini=val;
}
else
{
if(val
Thank you sir!
Great explanation
thanks bhaiya for explaining 2x-(2x-m)part
good one
nice explaination
🔥❤️
Bhai ye encrypt karne ke piche ka thinking bhi bata dete toh jada achha hota.
Pop is wrong. Neither the function is returning the value.. nor the v should be returned value. we need to calculate the value to be returned. If the value is greater than min then we can return top of the stack as it is. If it is lesser than min, then we need to return min value before changing the min
agar bhai sirf dsa karlo aur competetive na karo tab bhi company crack ho sakti hai kya?
Vro cp karo ya mat karo, interview main jo pooche wo aana chahiye bas!
why we are using (2x-min) trick if interviewer will ask the reason behind it then what we will say about it. I want to know intuition behind the (2x-min). If you can explain this then It will be very helpful for me.
Yaa bro we are using this formula so that we can get the previous minimum available in Stack
Aur mai woh deduction karke dikhaya na ki wapis hame "m" kaise mil raha h...wahi samjha dena
@@CodeLibrary ok
bcz overall value humme x se km rkhni hai N you can use any value instead of 2, bss at time of calculating new_min during pop function you have to use that new value you used during the time of encryption.
@@CodeLibrary Bro what if we only push the value in stack if it is less than the previous minimum and if not we dont push it by checking at every iteration
Are you planning to join any better company than Accolite?
he did