Gas Station (Google, Amazon, Uber, Microsoft, FactSet, Zoho, Flipkart) : Explanation ➕ Live Coding

  Рет қаралды 7,008

codestorywithMIK

codestorywithMIK

Күн бұрын

Пікірлер: 123
@nishant7083
@nishant7083 Жыл бұрын
Bro u ll be famous 3months juss 3 months
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Thats means a lot to me Nishant ❤️❤️❤️ Thanks a lot
@nishant7083
@nishant7083 Жыл бұрын
@@codestorywithMIK one request start funny and interesting explanation for dsa System design was really good
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Sure Nishant. Feedback taken Thanks a lot. Will keep this in mind ❤️❤️❤️
@nishant7083
@nishant7083 Жыл бұрын
@@codestorywithMIK you r reply faster than my reflexes ... Relfex-- , mik++
@codestorywithMIK
@codestorywithMIK Жыл бұрын
🙏😇😊😊😊
@tauquirahmed1879
@tauquirahmed1879 Жыл бұрын
People who make boring videos are afraid to make long videos. Whenever I see your video is long then I watching it intentionally thinking "Yr bhaiya ne zarur koi bht mast approach bataya hoga". Honestly I feel like, why I didn't come to know about your channel in my 1st year.
@codestorywithMIK
@codestorywithMIK Жыл бұрын
It means a lot Tauquir. Thank you so much ❤️❤️❤️
@annagarg2567
@annagarg2567 5 күн бұрын
((best)^(best))^(1/0)
@kartikeyparashar6563
@kartikeyparashar6563 16 күн бұрын
I am Pursuing my FULLSTACK Program from scaler. I just get my DSA Certification from SCALER as well. But, I just thought to keep practicing the Qs. I am watching your videos daily. Mtlb kya samjhaane ka tarika h yr aapka. Worth it to spend every single second on your KZbin Channel.
@souravjoshi2293
@souravjoshi2293 Жыл бұрын
Sorry NeetCode, no offence, but this guy has got some serious teaching skills. Explained it better than you. Man you are on fire 🔥🔥🔥🔥🔥🔥🔥
@codestorywithMIK
@codestorywithMIK Жыл бұрын
💪❤️
@divasbhadani9225
@divasbhadani9225 4 ай бұрын
Easiest Brute Force Approach: class Solution { public: bool completeCircuitUtils(vector& gas, vector& cost, int start) { int n = gas.size(); int j = start, tank = 0; do { tank += (gas[j] - cost[j]); if (tank < 0) { return false; } j = (j + 1) % n; } while (j != start); return true; } int canCompleteCircuit(vector& gas, vector& cost) { for (int i = 0; i < gas.size(); i++) { if (completeCircuitUtils(gas, cost, i)) { return i; } } return -1; } };
@RajanSingh-xr7cf
@RajanSingh-xr7cf 2 ай бұрын
bro when will i think like u
@namanbhatia9872
@namanbhatia9872 Жыл бұрын
sir, please make videos on dynamic programming concepts. I do not get to know that when to apply and solve problem by dynamic programming approach after reading the question.
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Planning it soon Naman. Thanks for your suggestion and watching my videos ❤️❤️❤️
@priyanshugautam5648
@priyanshugautam5648 Жыл бұрын
Bhaiya book allocation aur aise baaki binary search k hard Qns please smjha dijiye binary search ho jayega to confidence aayega please.... Thank you
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Sure Priyanshu. Planning soon Thanks for your suggestions 💪❤️
@udayshankar-e6v
@udayshankar-e6v 5 ай бұрын
Thoda execution speed or optimize ho sakta h , agar total kamai and totalkharcha loop me hi calculate kar le. and last me check laga de totalKmai < kharcha to return -1 else return result . Bahut aage jaoge bhai..bawal padhate ho😎
@ashmitpatel4829
@ashmitpatel4829 Жыл бұрын
Thank you sir for explanation Sir jab aap greedy ka question dekhte h to matlab aapko ye pta kaise chalta h ki isme greedy lagegi questions mein koi hint rehti h kya jisse aap pta kr paate ho ya practise se hi ayega
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Hi Ashmit, Actually there are two types of Greedy Qns which I have observed till now : 1) Very easy to figure out - Example : Maximum ice cream bars, where you had to just sort array so that greedily you buy cheapest ice creams 2) Tough ones - like this Qn “Gas Station”, These only come with practice. And tbh, I always forget this problem. But yeah, with practice only, these can be cracked.
@dayashankarlakhotia4943
@dayashankarlakhotia4943 7 ай бұрын
public int canCompleteCircuit(int[]gas,int[]cost){ int n=gas.length,total=0,position=0,sum=0; for(int i=0;i
@danishsaifi1038
@danishsaifi1038 Жыл бұрын
I was waiting for your video. Even though I was able to solve this question previously but could not able to solve it today. Feeling low 😥😥😥
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Don’t feel low. I also forgot the optimal approach. Many people did. So, don’t worry, these are rare qns, i know they demotivate, but let’s rise up and keep going ❤️❤️❤️ This qn is indeed wierd. But the explanation will make you love this qn I hope you like it.
@danishsaifi1038
@danishsaifi1038 Жыл бұрын
@@codestorywithMIK loved the explanation totalKamai & totalKharch.❤❤
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Thanks a lotttttt Danish ❤️❤️❤️
@Shivam-tu3lb
@Shivam-tu3lb 14 күн бұрын
Sir circle check m doubt hai please provide why we do not need to iterate complete circle in greedy
@mohammedwaseem8599
@mohammedwaseem8599 Жыл бұрын
The reason why optimized approach works is bcz it is said in question tht if solution exist then it will have unique index not multiple index.
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Indeed 💯
@prathamjiwnani6419
@prathamjiwnani6419 8 ай бұрын
why we are not checking for last index in optimised solution. I mean that can also be a possible answer?
@anmolverma075
@anmolverma075 2 ай бұрын
Here's the JAVA GREEDY SOLUTION - class Solution { public int canCompleteCircuit(int[] gas, int[] cost) { int totalKamayi = 0 , totalKharcha = 0 , n = gas.length; for(int i = 0 ; i < n ; i++){ totalKamayi += gas[i]; totalKharcha += cost[i]; } if(totalKamayi < totalKharcha) return -1; int total = 0 , result = 0; for(int i = 0 ; i < n ; i++){ total = total + gas[i] - cost[i]; if(total < 0){ total = 0; result = i + 1; continue; } } return result; } }
@Sakshi_Parmar
@Sakshi_Parmar 4 ай бұрын
Asa bhi to ho skta h ki jab hme end tkka result positive mila but then circular way me starting se iterate krna start kiya to negative me chala gya..please explain ki ye surety kaise h ki end tkka agr positive h to ans yahi index hoga ...
@ajinkyakhete1151
@ajinkyakhete1151 7 ай бұрын
Best video for this question hats off ....
@codestorywithMIK
@codestorywithMIK 7 ай бұрын
❤️❤️🙏🙏
@deepikasheshsrivastava4095
@deepikasheshsrivastava4095 Жыл бұрын
Best explanations. Thank you!
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Thanks a lot 😇
@oqant0424
@oqant0424 Жыл бұрын
bhaiya i wanted to ask u something i am currently in 4th year.. with no internship and ab tak koi job ni lagi and utni strong resume ni hai to kahin select bhi ni ho raha... samjh ni aa raha kya karun😢 i know pahle utne ache se mehnat ni ki..........but now i am doing it😶😣
@souravjoshi2293
@souravjoshi2293 Жыл бұрын
I am also in same situation brother. So, I have decided to code everyday and prepare everyday. It's never too late. All the best to you too
@oqant0424
@oqant0424 Жыл бұрын
@@souravjoshi2293 yes same here....what we can do is just to give our best every single day....All the best to you too! lets help each other till we reach our goal be in touch🙌
@oqant0424
@oqant0424 Жыл бұрын
sawal to samajh aa gaya tha ..but i was not even able come up with a brute force
@codestorywithMIK
@codestorywithMIK Жыл бұрын
No worries. That’s how we all learn and grow Always go for brute force first That’s why I discussed brute force
@oqant0424
@oqant0424 Жыл бұрын
@@codestorywithMIK thank u so much bhaiya........mark my words your channel will be discussed everywhere soon!
@codestorywithMIK
@codestorywithMIK Жыл бұрын
It means a lot to me ❤️❤️❤️ Hope the day comes and everyone soon starts quitting paid courses and focus on self study ❤️❤️❤️
@oqant0424
@oqant0424 Жыл бұрын
@@codestorywithMIK INDEED!
@ezcoding69
@ezcoding69 Жыл бұрын
agar aisa hi koi brute force & optimize approach explain and code kre to dsa mein master hone mein jyada smay nahi lagega...thanks sir ji
@codestorywithMIK
@codestorywithMIK Жыл бұрын
❤️💪💪❤️
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Thanks a lot 😇
@AnandKumar-kz3ls
@AnandKumar-kz3ls Жыл бұрын
when your total is less than 0 you set the next index as the answer how you can decide theres in between indexes where total >0 can also not produce the result
@oqant0424
@oqant0424 Жыл бұрын
how only checking till n-1 index ensures that it will cover the loop?
@RG-hm2er
@RG-hm2er Жыл бұрын
Was waiting for your video! Thanks
@nagmakhan672
@nagmakhan672 Жыл бұрын
Was waiting for your explanation
@akshhay
@akshhay Жыл бұрын
Amazing explain bhai ji 🫡🙏🙏
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Thanks a lot Akshay ❤️❤️❤️
@vijayninganure2049
@vijayninganure2049 Жыл бұрын
Nicely explained.. 🔥🔥 Keep posting daily. It will help us to understand the concept.
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Thanks Vijay ❤️❤️❤️
@lofireverbz-wy7go
@lofireverbz-wy7go 6 ай бұрын
was finding it hard to understand , but bhaiya trust me you u explained me this in one go❣❣
@abhinavkumar1356
@abhinavkumar1356 Жыл бұрын
Thank you brother 😊😊
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Thanks for watching Abhinav ❤️❤️❤️
@gui-codes
@gui-codes 4 күн бұрын
MIK = LEGEND of DSA
@kunal4710
@kunal4710 Жыл бұрын
VERY WELL EXPLAINED 🔥🔥🔥🔥🔥🔥
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Thanks a lot Kunal ❤️❤️❤️
@souravjoshi2293
@souravjoshi2293 Жыл бұрын
I was waiting for your explanation. Let's get started 🔥
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Hope you enjoy it!
@molyoxide8358
@molyoxide8358 Жыл бұрын
Bro I get the answer of 'WHY this?' "why not that" very clearly from your channel. Thanks a lot & already subscribed just before you changed the channel's name.
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Thanks a lot ❤️❤️❤️ It means a lot 😇😇😇
@subhodeepmaji5997
@subhodeepmaji5997 Жыл бұрын
Didn't prove why we will have solution if total_kamai > total_kharcha. Just said greedy hai, intuition se ho jata hai. Correct me if I am wrong, pura video nahi dekha.
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Hi Subhodeep, This was my thought process actually. I greedily assuming that condition. May be , you can share your thought process also, I would be more than happy to explore it together Thanks a lot for watching ❤️❤️❤️
@akshatsaxena8024
@akshatsaxena8024 Жыл бұрын
Thanku so much for such a great explanation I really enjoyed and Its becomes very hard for me to forget 😁😁😁😁😁😁
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Wow Thanks a lot Akshat ❤️❤️❤️
@amanbalhara7365
@amanbalhara7365 Жыл бұрын
Very well explained, i was searching for this kind of video nd I got it , it helped alotttt. Thnku sooo much!!!! ❤️
@codestorywithMIK
@codestorywithMIK Жыл бұрын
So glad to hear. Thanks a lot Aman ❤️❤️❤️
@wearevacationuncoverers
@wearevacationuncoverers Жыл бұрын
I didn't find a better explanation to this video in the entire internet. You are just amazing
@samannwaysil4412
@samannwaysil4412 Жыл бұрын
Wow , such explanation...
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Thanks a lot 😇😇😇 Hope 1M comes soon 😃
@udaytewary3809
@udaytewary3809 Жыл бұрын
You are really sensational bhaiya while I was solving the question and not able to understand the question and just by watching you for few second I git understand the problem really well and for that I am really really thankyou bhaiya. And mark my words bhaiya you are going to create a great change in the thinking ability of ours and for this we will be always great full to you 🤗🤗🤗
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Wow Thanks a lo Uday ❤️❤️❤️
@manish6801
@manish6801 Жыл бұрын
I scroll through whole comment section 😀 whatever others say it's definitely true bro. You have really unique teaching stylish and lovely 😍😍. Can you please make a video on Kth smallest element in two sorted array/median of array??
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Thanks a lot Manish. ❤️❤️❤️ Noted for Kth Smallest Element, Coming soon
@nagmakhan3165
@nagmakhan3165 Жыл бұрын
I think this is the only indepth video on this problem 🔥🔥🔥
@amansrivastava1360
@amansrivastava1360 Жыл бұрын
Awesome Bhai👍
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Tysm 💝
@atmanirbharofficialindiaon2789
@atmanirbharofficialindiaon2789 Жыл бұрын
Subscribed straight away after this level of explanation from a question which was bugging me for months
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Means a lot ❤️❤️❤️
@abhinay.k
@abhinay.k Ай бұрын
thank you sir
@piyushacharya7696
@piyushacharya7696 Жыл бұрын
Thanks a lot for mentioning me bro😎😎 If you ever wish to use that thumbnail then I can provide you the template bro. reach++++
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Thanks a lot Piyush ❤️❤️❤️❤️
@piyushacharya7696
@piyushacharya7696 Жыл бұрын
@@codestorywithMIK vai mein ye optimal samajh nahi paraha kaise kisi index se hum end tak pahoch gaye toh woh hi ans hai?
@danishsaifi1038
@danishsaifi1038 Жыл бұрын
@@piyushacharya7696 Wo ans islie hai kuki humne pehle hi check kr liya sum of gas and sum of cost ko calculate krke agar sum of gas kabhi bhi kaam hoga to possible hi nahi hai k hum kitni bhi cost deke pura circle complete kr sake. or agar hum use case se bach gae or result_Index search krne aae hai to its means there should be an answer which going to be always present.
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Correct 💯
@piyushacharya7696
@piyushacharya7696 Жыл бұрын
​@@danishsaifi1038 yeah, now I got it. Sar dard qn hai yeh sach mein😂😂
@danianiazi8229
@danianiazi8229 Жыл бұрын
I like your videos, you tell about the question history it repitation stats and its importance so who eevr are preparing might not get scared.
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Thanks a lot Dania 😊
@pranaymishra5456
@pranaymishra5456 3 ай бұрын
face revealed at 2:20
@anmolverma075
@anmolverma075 2 ай бұрын
Thank you sir for such a great explanation!! Was able to code the greedy solution by myself after you explained. Most underrated gem on YT.
@sanjaykatta6499
@sanjaykatta6499 10 ай бұрын
It has some (very very small) similarities with Kadane's algorithm - as soon as we are running out of fuel (ending with net zero fuel), we are discarding it and starting with the whole new index.
@vishalplayzz2580
@vishalplayzz2580 Жыл бұрын
i dint do this :/
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Now you can 😇❤️😊💪💪💪💪 Let’s watch the video and learn 💪💪💪
@alphadrones23
@alphadrones23 Жыл бұрын
awesome... skip karne ka mann hi nai karta.....
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Thanks a lot Akhil ❤️❤️❤️
@manish6801
@manish6801 Жыл бұрын
Even i lost in story 😃😃
@deepankar9964
@deepankar9964 Жыл бұрын
God level
@codestorywithMIK
@codestorywithMIK Жыл бұрын
❤️❤️❤️💪💪💪
@OtakRajCodes
@OtakRajCodes Жыл бұрын
Your explanation is top notch . also love that u explain both brute force and greedy solution
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Thanks a lot Raj ❤️❤️❤️
@YashSinghal
@YashSinghal Жыл бұрын
question was soo confusing but your solution was amazing
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Thanks a lot Yash ❤️❤️❤️
@harshdiwan9283
@harshdiwan9283 Жыл бұрын
Superb♥. Maza aa gya bhai
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Thanks a lot Harsh ❤️❤️❤️
@harshdiwan9283
@harshdiwan9283 Жыл бұрын
@@codestorywithMIK bhai in place of accumulate what we can use in Java ?
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Hi Harsh, i think there is no such shortcut in java. I am also not too well aware of java. If i get to know , i will share for sure
@shashankshandilya1517
@shashankshandilya1517 Жыл бұрын
Thank You for the Explanation
@codestorywithMIK
@codestorywithMIK Жыл бұрын
I am glad it helped ❤️❤️❤️
@prashantsharma2569
@prashantsharma2569 2 ай бұрын
Nahi milega koi inke jaisa jao aajma lo🥹🥹🥹 Lots of respect sir🙏🏼🙏🏼🙏🏼🙏🏼🥹
@parishjain4705
@parishjain4705 Жыл бұрын
no words how amazing you are
@molyoxide8358
@molyoxide8358 Жыл бұрын
Bro Udemy pe koi CP se realated course hai kya??
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Hey, Sorry I am not aware of this. May be you can try searching on Quora or google, someone might have answers
LRU Cache | Brute Force | Optimal | Detailed | Leetcode 146
40:32
codestorywithMIK
Рет қаралды 15 М.
小天使和小丑太会演了!#小丑#天使#家庭#搞笑
00:25
家庭搞笑日记
Рет қаралды 33 МЛН
Spongebob ate Michael Jackson 😱 #meme #spongebob #gmod
00:14
Mr. LoLo
Рет қаралды 10 МЛН
哈莉奎因怎么变骷髅了#小丑 #shorts
00:19
好人小丑
Рет қаралды 54 МЛН
Gas Station - Greedy - Leetcode 134 - Python
15:47
NeetCode
Рет қаралды 132 М.
LFU Cache - (Microsoft)  :  Explanation➕Live Coding
49:29
codestorywithMIK
Рет қаралды 8 М.
CANDY | 2 Approaches | O(1) Space | O(N) Space | AMAZON | Leetcode - 135
39:33
Remove K Digits | Intuition | Dry Run | Leetcode 402 | codestorywithMIK
35:07