Minimum Stack - 2 | Solution

  Рет қаралды 22,068

Pepcoding

Pepcoding

Күн бұрын

Пікірлер: 61
@arshadahmad9264
@arshadahmad9264 9 ай бұрын
Har topic ko apne bahut achche se explain kiya. Now you are my favourite teacher.
@AyushKumar-fk5lm
@AyushKumar-fk5lm 3 жыл бұрын
Sumeet sir is a gem! Waiting to see amazing Pepcoding team hitting 50k subscribers in 24-48 hrs!!
@Pepcoding
@Pepcoding 3 жыл бұрын
Hope so Beta. keep motivating, keep learning and keep loving Pepcoding😊
@travelnlearn
@travelnlearn Жыл бұрын
Aap jaisa sir ho toh koi bhi subject samjh aayega hi aayega Love you sir ♥️
@444not
@444not 3 жыл бұрын
Thanks for all your effort. Your teaching style in really amazing. I am learning a lot. Cannot thank you enough. I have watched the same approach in a different video, but it didn’t stick. Watching you solve this 5 times made me understand the concept very well.
@AmanTheMystery
@AmanTheMystery 3 жыл бұрын
sumit sir is king sir itna deep koi nhi smjta sir . esa lagta hai jese aap k samne baith k class le rhe hai thank u sir hum bacho ko itna acha content dene k liye
@Pepcoding
@Pepcoding 3 жыл бұрын
Thank you so much for appreciating and If you like the content could you post something on LinkedIn about us? This will help us in reaching out to more people and help a lot of other students as well Something like this Sumeet Malik from Pepcoding is making all his content freely available to the community You can check it out here - www.pepcoding.com/resources / Also, this is the youtube channel - kzbin.infoplaylists?view_as=subscriber
@kandurimanohar8211
@kandurimanohar8211 3 жыл бұрын
I understood the concept what you explained sir but I didn't understood the reason for Implication why we are doing v+v-m when v
@Jaganantpatil6711
@Jaganantpatil6711 8 ай бұрын
This trick is to find previous min when you do pop() to achieve complexity
@bloody9162
@bloody9162 3 жыл бұрын
The What, How and Why is Gold. I'm going to apply this to other aspects of my life as well :)
@Pepcoding
@Pepcoding 3 жыл бұрын
Glad it helped, for better experience, doubt support and career opportunities with same but well-organised content, visit - nados.pepcoding.com Don't forget to follow us on Instagram instagram.com/pepcoding/
@Pepcoding
@Pepcoding 3 жыл бұрын
Means a lot! Also for better experience and well-organised content Visit - nados.pepcoding.com Don't forget to follow us on Instagram instagram.com/pepcoding/
@GyaanGrave
@GyaanGrave 2 жыл бұрын
This is some amazing teaching. God gifted.
@stith_pragya
@stith_pragya Жыл бұрын
Thank You So Much Sumeet Sir...........🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻
@dheerajkhushalani2619
@dheerajkhushalani2619 3 жыл бұрын
amazing question to solve.. thank you sir for your explanation..
@mohitahlawat4944
@mohitahlawat4944 3 жыл бұрын
woahh out of the box explanation sir, thanks for such great content
@mrityunjayjaiswal3801
@mrityunjayjaiswal3801 2 жыл бұрын
Awesome sir. From TOday i am your big fan
@ParasVashishth_RV
@ParasVashishth_RV 3 жыл бұрын
Sir, very nice logic, will keep a note of this method. Thnx
@ParasVashishth_RV
@ParasVashishth_RV 3 жыл бұрын
but max stack ka aise direct toh ni milrha logic
@Pepcoding
@Pepcoding 3 жыл бұрын
Thanks buddy! I am glad you liked it. If you like our efforts, will you like to write a few words about us here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms ) Keep learning and keep supporting Pepcoding😊
@sarthaktripathi468
@sarthaktripathi468 3 жыл бұрын
sir iss question ko to sidha bhi kar sakte the, min variable banate and stack 1)pahale dono mei data push karte. 2) jab next bar data push karte to min se compare kar lete 3)agar min se chota aat to min to update kar lete. fir shyad v+(v-min) karne ki jarurat nhi pdhti?
@chetanmehta3957
@chetanmehta3957 3 жыл бұрын
There would be problem when the min element gets popped. U will not know about the next min if you dont maintain the state through the formula in the stack itself
@SCRIPTSAG
@SCRIPTSAG 4 жыл бұрын
Sir mst explain kiya sir ds algo ka bahut use hota hoga industry me time space ke term me ye code chela do to shi hi hai na sir time bachega hi
@swatidubey493
@swatidubey493 2 жыл бұрын
thank you so much sir for this amazing explanation .
@travelnlearn
@travelnlearn Жыл бұрын
Will definitely grab a pbc and come and talk to you sir
@DataMetricsSolutions
@DataMetricsSolutions 3 жыл бұрын
You are my GOD sir
@prateekbansal2014
@prateekbansal2014 3 жыл бұрын
Sir isme aapne val+val - min kra ..... agar sirf val - min kre to bhi code chal rha hain correct ans aa rha hain ... to kya val - min bhi sahin hain ??
@prateekbansal2014
@prateekbansal2014 3 жыл бұрын
Well I just do dry run for val-min case .... in case of negative numbers val-min will fail but val+val-min will work
@namanagrawal4868
@namanagrawal4868 2 жыл бұрын
thanks for the explaination :)
@adityagupta1805
@adityagupta1805 3 жыл бұрын
Awsm logic
@codemaestro9904
@codemaestro9904 4 жыл бұрын
Awesome explanation sir. I tried this approach on leetcode but it failed on 1 testcase: push(2147483647) (Integer.MAX_VALUE) push(-2147483648) (Integer.MIN_VALUE) min() top() pop() I think there's some overflow here. Sir could you help me understand the problem in this case?
@Pepcoding
@Pepcoding 4 жыл бұрын
beta long use kar le. pass ho jaega.
@ankitkumarmahato4318
@ankitkumarmahato4318 3 жыл бұрын
@@Pepcoding nhi ho rha sir
@Anonymous_Coder
@Anonymous_Coder 2 жыл бұрын
@@ankitkumarmahato4318 Try to make stack of long long and mini of also long long .. It will definitely pass.
@zonemasterindia
@zonemasterindia 2 жыл бұрын
not working on LeetCode
@AKASHKUMAR-li7li
@AKASHKUMAR-li7li 6 ай бұрын
but sir, this solution might give integer overflow....... error , in case the number in int_min how to solve that issue
@akashkumar-kz3ch
@akashkumar-kz3ch 4 жыл бұрын
sir, but can we put display function in min stack class and what logic we be applied in that
@Pepcoding
@Pepcoding 4 жыл бұрын
Beta, I regret to inform you that, I won't be able to answer/solve the personal doubts of each and every student over here. For clearing your doubts, you can join our community on telegram - t.me/pepcoding. Also, we have a premium facility available for the students in which you can get the 12 hours doubt support facility. Jisme aap agr kisi bhi question main kahin bhi faste ho to aap doubt support par reach kar skte ho aur aapko TA assign ho jayega and you can get your doubt resolved from them.
@vishalsingh2408
@vishalsingh2408 3 жыл бұрын
Very detailed and nice explaination
@Pepcoding
@Pepcoding 3 жыл бұрын
Thanks buddy! Keep watching and keep learning😊
@lakshayrastogi2347
@lakshayrastogi2347 3 жыл бұрын
SIR yeh sb humne bs O(1) LAANE k liye kia h n?
@prateekbansal2014
@prateekbansal2014 3 жыл бұрын
sir yeh technique apne sochi kese ?? kya pehle se hi exist krti thi ya apne khud bnayii ... khud bnayii to kya logic lgaya ??
@Pepcoding
@Pepcoding 3 жыл бұрын
Post your doubts on nados.pepcoding.com our community will help you out.
@codemaestro9904
@codemaestro9904 4 жыл бұрын
Sir agar min ki jagah max stack bnani hoti toh kya store krte ?
@Pepcoding
@Pepcoding 4 жыл бұрын
1 trick could be to change the sign of numbers. while taking a number multiply by -1 and while giving back again multiply by -1
@Pepcoding
@Pepcoding 4 жыл бұрын
now min stack will behave like max stack. keep rest of the logic same.
@codemaestro9904
@codemaestro9904 4 жыл бұрын
Thanks sir :)
@entertainshala
@entertainshala 2 жыл бұрын
Hi, why did you use v+v-m but now v-m??
@kashba
@kashba 2 жыл бұрын
negative values ke liye dry run karo. fail kar jayega push -> 30, 5, 17, -1, -3, 10 and do it with v - m method. it will fail. Hmara goal hota hai detection ke liye value bnana jab value in st < min hogi tab hmara original value current min se kam value aayi hogi but it won't work with v - m
@LegitGamer2345
@LegitGamer2345 4 жыл бұрын
awesome!
@Pepcoding
@Pepcoding 4 жыл бұрын
Thank you! Cheers!
@anubhavtyagi6502
@anubhavtyagi6502 3 жыл бұрын
sir using min variable won't affect the space complexity?
@aahanaganjewar9951
@aahanaganjewar9951 2 жыл бұрын
No
@yashgupta9677
@yashgupta9677 3 жыл бұрын
Sir humne isme v+v-m hi kyu kara?? v-m se bhi krskte h na?
@chetanmehta3957
@chetanmehta3957 3 жыл бұрын
Yadi dono no- v, m negative honge toh simple v-m kam nahi karega
@_s_h_l_o_k_
@_s_h_l_o_k_ 3 жыл бұрын
Liked the content sir, But can we add one variable previousMin and while popping if min==stack.peek() then we'll update min from previous min. Its still O(1) complexity...?
@Pepcoding
@Pepcoding 3 жыл бұрын
For such query visit on nados.pepcoding.com, you can post your query on Community tab. And you will find better experience with organised content. Don't forget to follow us on Instagram instagram.com/pepcoding/
@SCRIPTSAG
@SCRIPTSAG 4 жыл бұрын
Sir pichle logic aur es logic me bas yhi difrence hai ki jeb hem pus kerta hai to extra space ke liye stack me save nhi ker rha hai bali uski stack me save kerke aur fir se pta kerne ke kiye aisha signature dal rhe hai taki wo fir se mil ske ager hem pop kre to i think yhi difrence hai en dono question me
@Pepcoding
@Pepcoding 4 жыл бұрын
ji bilkul
@SCRIPTSAG
@SCRIPTSAG Ай бұрын
I just got after 4 years mai yhi problem ek bde engineering collage me pdaunga kel
Sliding Window Maximum | Solution
21:15
Pepcoding
Рет қаралды 80 М.
Machine Learning for Everybody - Full Course
3:53:53
freeCodeCamp.org
Рет қаралды 8 МЛН
Мама у нас строгая
00:20
VAVAN
Рет қаралды 11 МЛН
Long Nails 💅🏻 #shorts
00:50
Mr DegrEE
Рет қаралды 16 МЛН
L4. Implement Min Stack | Stack and Queue Playlist
20:55
take U forward
Рет қаралды 46 М.
Celebrity Problem | Solution
11:53
Pepcoding
Рет қаралды 77 М.
Implement Min Stack | O(2N) and O(N) Space Complexity
22:44
take U forward
Рет қаралды 91 М.
Largest Area Histogram | Solution
20:05
Pepcoding
Рет қаралды 73 М.
Max frequency stack || Leetcode
19:41
Pepcoding
Рет қаралды 5 М.
Next Greater element on the right | Solution
16:27
Pepcoding
Рет қаралды 82 М.
Errichto Stream, POI 22/1
3:55:08
Errichto Algorithms
Рет қаралды 171 М.
Infix Conversions | Solution
21:56
Pepcoding
Рет қаралды 22 М.