BS-20. Minimise Maximum Distance between Gas Stations | 3 Approaches | Heap | Binary Search

  Рет қаралды 115,232

take U forward

take U forward

Жыл бұрын

Problem Link: bit.ly/43SkwqA
Notes/C++/Java/Python codes:
We have solved the problem, and we have gone from brute force and ended with the most optimal solution. Every approach's code has been written in the video itself. Also, we have covered the algorithm with intuition.
Full Course: bit.ly/tufA2ZYt
You can follow me across social media, all my handles are below:
Linkedin/Instagram/Telegram: linktr.ee/takeUforward
0:00 Introduction of Course

Пікірлер: 294
@takeUforward
@takeUforward Жыл бұрын
My bad, a small correction in the code: if((arr[i] - arr[i-1]) == (dist * numberInBetween)) { numberInBetween--; } 1 == (2 * 0.5)
@Gamingnoobop
@Gamingnoobop Жыл бұрын
bhai gfg ki link striver A2Z me add karo plz striver sheet is incomplete without gfg
@parthibchowdhury5558
@parthibchowdhury5558 Жыл бұрын
I am confused.. how it is passing all the test cases then? By the way, Great Explanation love it😇
@harshitshukla1974
@harshitshukla1974 Жыл бұрын
@@parthibchowdhury5558 I was having the same doubt.. I think it is because the datatype used is "int" and the test cases are weak so there is no test case present where actually the value(arr[i]-arr[i-1]) is perfectly divisible by dist ...because even if you remove this if condition and dont do the decrement, then also the code is working completely fine.
@shubham_v
@shubham_v Жыл бұрын
Some test cases are failing because of this condition on gfg, after removing it all cases passed. I'm still confused why this is happening.
@shubhrajyotipoddar1684
@shubhrajyotipoddar1684 Жыл бұрын
if(fmod((long double)(arr[i+1]-arr[i]),mid)==0) numberInBetween--; modulus work only in case of int so fmod
@visheshupadhyay1774
@visheshupadhyay1774 6 ай бұрын
Striver is trying his very best to explain but the problem itself is very complex. Hats off bro...
@sleepypanda7172
@sleepypanda7172 Жыл бұрын
What a noble man. May he achieve all the success that he wants
@sohamgaikwad15
@sohamgaikwad15 7 ай бұрын
he had already achieved it
@user-oz2eu7rs8v
@user-oz2eu7rs8v 3 ай бұрын
@@sohamgaikwad15 still more go
@habeeblaimusa4466
@habeeblaimusa4466 Жыл бұрын
Guys those of you saying use low
@infinityzero2321
@infinityzero2321 Жыл бұрын
I think all almost all of them😅
@ganjinaveen7338
@ganjinaveen7338 11 ай бұрын
@@infinityzero2321 yes bro
@GeneralistDev
@GeneralistDev 11 ай бұрын
please explain here only, I don't have time to go through whole playlist
@farazahmed7
@farazahmed7 9 ай бұрын
@@GeneralistDev nhi bateynege poora dekh
@arunm619
@arunm619 25 күн бұрын
@@GeneralistDev its just a pattern we follow to solve the problems to get the polarity principle where the answer we are looking for always resides at low index for y.y.y.y.n.n.n.n.n problems.
@kiranmoura2974
@kiranmoura2974 Жыл бұрын
Sir please continue the series ...a lot of students are waiting eagerly for your videos .
@zaidwani1473
@zaidwani1473 5 ай бұрын
This guy is a pure genius. The efforts he put in to explain such a complex problem with such simplification requires a genius mind. Kudos to your efforts.
@stith_pragya
@stith_pragya 5 ай бұрын
Though Striver Bhaiya is at a very nice position today, but according to me, he deserves even more...................God Bless You Bhaiya.........🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻 Thanks a ton..........🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻
@i_m_phoenix87
@i_m_phoenix87 11 ай бұрын
it's so hard to wait for gem videos like this , I got a very clear view of BS just because of you bhaiya. Thanks
@SarthakKumar
@SarthakKumar 11 ай бұрын
Dedication, Made Respect to him!! GIving a complete insight on the topic is just insane and very few people do it!
@rohitsai806
@rohitsai806 10 ай бұрын
Hard problem to absorb...! Kudos to your efforts, hats off Striver for your dedication
@Shunya_Advait
@Shunya_Advait 11 ай бұрын
Understood Sir, It is most amazing problem I find in binary search and really required more attention, and Sir you have explained it very well in three different approaches , thanks a lot for the video.
@cinime
@cinime Жыл бұрын
Understood! Super amazing explanation as always, thank you very much for your effort!!
@himanshuranjan8344
@himanshuranjan8344 Жыл бұрын
Effort level:- Inspirational 🏆
@Entertainmentexe
@Entertainmentexe Жыл бұрын
The best DSA course on the Internet
@niharbastia5740
@niharbastia5740 Жыл бұрын
Amazing explanation so far🔥
@neemaparnami8604
@neemaparnami8604 Ай бұрын
Can't thank you enough for this amazing content!! Explained so perfectly!! Thank you Striver for this course!!
@stith_pragya
@stith_pragya 5 ай бұрын
UNDERSTOOD...........Thank You So Much for this wonderful video..............🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻
@harshitjaiswal9439
@harshitjaiswal9439 6 ай бұрын
Amazing! Dedication is super! Thank you Striver!
@someshsunar4166
@someshsunar4166 3 ай бұрын
Great Approach. Really loved the explanation. You made such an hard question easy to understand. Thanks❤❤
@Gaurav-vl6ym
@Gaurav-vl6ym 9 ай бұрын
no one explains better than you ,thank you
@apoorvasingh5702
@apoorvasingh5702 2 ай бұрын
Thank you for explaining this difficult question so brilliantly.
@udaypandey5659
@udaypandey5659 Жыл бұрын
Bhai last decimal vala sach me hard h... 2 solution to iska easily samjh gaya. I will give again try tom , at least 30 % aaj samjh me aa gaya.
@beinginnit
@beinginnit Жыл бұрын
Thank you so much Striver.Loved it.💖
@harshitpatil6138
@harshitpatil6138 5 ай бұрын
Very well understood all three approaches specially priority queue one method
@valavalalohitkumar1348
@valavalalohitkumar1348 Жыл бұрын
UnderStood Striver, and that's awesome. Thanks for making this
@-RAJSINGH
@-RAJSINGH 9 күн бұрын
Best explanation! this was my first hard problem, but you made it so easy to understand. Hats off bhaiya!!!!
@b_01_aditidonode43
@b_01_aditidonode43 6 ай бұрын
hats off to your efforts sir, very well explained
@EngineerStrange
@EngineerStrange 2 ай бұрын
Hats off to the explanation. Awesome work sir
@preetisahani5054
@preetisahani5054 9 ай бұрын
Awesome explanation. still trying to absorb last approach
@yashshetty7326
@yashshetty7326 10 ай бұрын
Words cannot portray how much grateful I am to you and your teaching. Never ever I have understood a topic with such clearness and depth. Thanks to you I could solve all the problems right from Aggressive cows till Painter's Partition without even looking at any hints.Cannot explain the surreal feeling of getting green ticks on a LC Hard problem that too in the first submission itself!!
@shantipriya370
@shantipriya370 7 ай бұрын
just wow.. u really inspire me sir..
@DR-mq1le
@DR-mq1le 11 ай бұрын
striver bhaiya when can we expect the strings playlist? ur explanation is far better than anyone else . and before the fanboys come at me saying that " striver has a job , have patience" , im just asking when we can expect not forcing him :)
@arghyadeepbhowmick2248
@arghyadeepbhowmick2248 10 ай бұрын
Great video sir! Hats off!
@user-ik3qu5uy5e
@user-ik3qu5uy5e 5 ай бұрын
sir ek hi dil hai kitne baar jeetoge ❣
@girikgarg8
@girikgarg8 10 ай бұрын
Done! Nicely explained
@yaminireddy3321
@yaminireddy3321 27 күн бұрын
Thank You Striver for the best explaination
@sujalgupta6100
@sujalgupta6100 2 ай бұрын
I would rather fail interview than trying this binary search solution took me 3 hours to make through this video
@harshilpatel3205
@harshilpatel3205 5 ай бұрын
Hats off to your hardwork brother 🤍🫡
@Dontpushyour_luck
@Dontpushyour_luck 9 ай бұрын
did this question even before watching video. you taught binary search so good that I was able to do it so easily
@nookalareshwanth1785
@nookalareshwanth1785 6 ай бұрын
This surely is an amazing problem
@playwithlinux
@playwithlinux Ай бұрын
Amazing content bro... Love you so much
@ambaradhikari7425
@ambaradhikari7425 Жыл бұрын
Good explanation, please start string then linkedlist, also please add gfg links
@Bhalu-kl7sq
@Bhalu-kl7sq 12 күн бұрын
maybe high have to watch again after sometime awesome video
@devils9844
@devils9844 Жыл бұрын
Why are the videos not coming? please make a video regarding when the future videos will be released. I am very excited.
@Entertainmentexe
@Entertainmentexe Жыл бұрын
you're doing great job
@hiteshpanchal5239
@hiteshpanchal5239 Жыл бұрын
Striver bhai plzz start string series i am waiting for it.... ❤️❤️❤️
@vrushabhjoshi3155
@vrushabhjoshi3155 25 күн бұрын
Hats off to your hard work 🫡
@jayant1407
@jayant1407 Жыл бұрын
hey Striver , Just a Small request sir can pls give us the , List of Topics that you will be covering monthly So it will easy for us to knew till when we are able to complete the dsa
@techskool5274
@techskool5274 Жыл бұрын
Yes pls 😊
@devils9844
@devils9844 Жыл бұрын
yes
@kabirkapoor9149
@kabirkapoor9149 11 ай бұрын
Yesss please Striver
@adityaraj402
@adityaraj402 Ай бұрын
His efforts>>>>
@AKASHKUMAR-li7li
@AKASHKUMAR-li7li 4 ай бұрын
You are just awesome man👍
@ashutoshjha2648
@ashutoshjha2648 10 ай бұрын
keep up the good work bro...
@AmanKumar-qz4jz
@AmanKumar-qz4jz 10 ай бұрын
THANKU SO MUCH SIR!!! LOVE U MAN
@madhabtripathy8691
@madhabtripathy8691 5 ай бұрын
From Bruteforce -> better -> optimal. It was really hard question in BS. But anyways Thank You Striver for best explanation.
@atharva..deshmukh
@atharva..deshmukh 19 күн бұрын
Very nice explanation
@subhrajsingh
@subhrajsingh 5 ай бұрын
best video till date
@amanupadhyay8628
@amanupadhyay8628 10 ай бұрын
you are great bhaiya love you❤
@knowthrvdo
@knowthrvdo 5 ай бұрын
NICE VIDEO UNDERSTOOD !!!
@kabirkapoor9149
@kabirkapoor9149 11 ай бұрын
Striver please please please Continue with the series ..... Placements are approaching , Completely dependent on ur way of teaching .....Kindly upload videos and complete dsa as early as possible
@DR-mq1le
@DR-mq1le 11 ай бұрын
final year aswell?
@arnab027
@arnab027 11 ай бұрын
please striver post the next videos asap we are eagerly waiting for ur vds please, placement start ho gya please complete the series
@prabhatmishras421
@prabhatmishras421 20 күн бұрын
Madddd Respect man♥♥
@hashcodez757
@hashcodez757 5 ай бұрын
last wali ne dimaag hila daala bhai!!
@simarjeetkaur6781
@simarjeetkaur6781 11 ай бұрын
Sir pls continue the series..
@heavenlyway5824
@heavenlyway5824 Жыл бұрын
I appreciate everything you're doing. However, my only suggestion is, can you keep dark mode while writing code.
@YourCodeVerse
@YourCodeVerse 7 ай бұрын
Understood✅🔥🔥
@abdussalam-4836
@abdussalam-4836 11 күн бұрын
A small improvement in brute force is u don't need to have a howmany vector u can use the pair in pq
@anugandulasricharan3735
@anugandulasricharan3735 4 күн бұрын
Thanks.Understood
@azmirvali6205
@azmirvali6205 Жыл бұрын
Bayya please make sure in SDE sheet the you tube video should be play in other page when we click to watch
@bhavya8608
@bhavya8608 Жыл бұрын
Understoood!!!!!
@Freefire-hp4zz
@Freefire-hp4zz Жыл бұрын
Bhai Will You Continue To Upload DSA COURSE VIDEOS AFTER BINARY SEARCH??? PLEASE UPLOAD STRING PLAYLIST BHAI
@JayPatel-sn7it
@JayPatel-sn7it Жыл бұрын
Bhai site thik kar rahe ho to sath me CN ki jagah GFG ki link dal do please... Or you can make another section beside of CN links, for GFG links please 🥺
@knowledgedoctor3849
@knowledgedoctor3849 11 ай бұрын
Stack & Queue Series Please Also Linked List.
@user-tk2vg5jt3l
@user-tk2vg5jt3l 5 ай бұрын
Thank you Bhaiya
@jashhinger442
@jashhinger442 7 ай бұрын
Striver you are GOD!!!
@shatwikshankar05
@shatwikshankar05 Жыл бұрын
Absolutely loving your SDE sheet ….please just make a video on Rabin Karp algo and KMP algo…thoda bouncer jara hai uska concepts.
@grette4156
@grette4156 11 ай бұрын
Where can I find it ?
@shatwikshankar05
@shatwikshankar05 11 ай бұрын
@@grette4156 search on google-striver sde sheet
@sanchitkanojia5460
@sanchitkanojia5460 Жыл бұрын
bhaiya jo aapne website par arrays ki playlist ke upar brute force, better and optimal solution ka new feature ek hee page par diya hai. bss hame column par click karna hoga woh feature baaki playlists par bhi apply kar dijiye. Tree, Graph, aur DP abhi purane feature ke hisaab se he hai.
@sdsingh3577
@sdsingh3577 Жыл бұрын
Plz bhaiya upload more and more videos as soon as possible......plz bhaiya
@Daddy30011
@Daddy30011 Жыл бұрын
Th ode question khud se bhi try kiya karo 🥲
@sdsingh3577
@sdsingh3577 Жыл бұрын
@@Daddy30011 not question bro.....I say introduction tutorial of pointer and some other
@aps8874
@aps8874 9 ай бұрын
Super❤‍🔥
@sunilpatidar8609
@sunilpatidar8609 Жыл бұрын
bhai can yu tell how many month yu will take complete this course actually i am new this chanel approx 3 month
@anupamtiwary4265
@anupamtiwary4265 29 күн бұрын
thank you
@bharathi66
@bharathi66 9 күн бұрын
Understood Bhai
@sanjayp.m7008
@sanjayp.m7008 Жыл бұрын
why is the site of takeyouforward down?? please fix it as soon as possible as many are using sde sheet and a2z sheet form there
@dibasbiswal3020
@dibasbiswal3020 Жыл бұрын
Bhai please continue the series
@LolLol007
@LolLol007 Жыл бұрын
Subscribed Nice👌
@HARSHKAJALKHANEIIIIIIII
@HARSHKAJALKHANEIIIIIIII 2 ай бұрын
Instead of checking if the mid exactly divides arr[i+1]-arr[i] or not, we can directly do ceil((arr[i+1]-arr[i]) / mid) - 1 to avoid that issue.
@priyeshtandel2101
@priyeshtandel2101 Жыл бұрын
Understood
@sauravchandra10
@sauravchandra10 Жыл бұрын
I dont think we need the line if((arr[i] - arr[i-1]) == (dist * numberInBetween)) { numberInBetween--; } Beacause even if you remove this line of code, the code gets submitted. I think this is because if we dont have this line, the cnt will be overestimated and so it will automatically execute low=mid and in doing so, it will further execute the high=mid calls and we will reach a answer closer to the actual ans with diff less than 1e-6
@kritikasingh4876
@kritikasingh4876 Жыл бұрын
Bhaiya u got the ipad and you are great at explaining things..but its too tough to explain in interview in such a pressure situation😢
@anandsinha2289
@anandsinha2289 Жыл бұрын
But try to give all the approach it will be the edge factor in the interview
@archanasingh6382
@archanasingh6382 Жыл бұрын
@takeuforward i am preparing dsa referring your all videos. Is there anything else that i have to prepare. I have 8 years experience as java developer. I am preparing for google. Please let me know.
@yugal8627
@yugal8627 Жыл бұрын
Hi, Striver I had asked you in your previous videos when to use while(high-low>1) like conditions. Put some light on it.🙂
@takeUforward
@takeUforward Жыл бұрын
I said repeatedly, we solve all the problems with while(low
@project_eth
@project_eth Ай бұрын
holy sh*t this question was hard to understand, but seriously man what an explanation!
@tempregex8520
@tempregex8520 10 ай бұрын
but, im not understanding why to calculate the maxVal in the previous for loop?
@shameekagarwal4872
@shameekagarwal4872 5 ай бұрын
sorry, i cudnt catch the time complexity of the binary search solution. is it O(N + (log(high * 10^6) * N))?
@hazarath6904
@hazarath6904 Ай бұрын
True to your name, Striver.
@sairamyakamalibandla7667
@sairamyakamalibandla7667 Жыл бұрын
problem: You have a list of numbers that are sorted in increasing order. You also have two numbers, K and X. Your task is to find the K numbers in the list that are closest to X. If two numbers are equally close to X, you should choose the smaller one. For example, if the list A is [2, 6, 7, 10] and K is 2 and X is 8, then the closest numbers to 8 are 7 and 6. Hi. Could you create a binary search video for this "K closest element problem".😶 ps: I have been following your binary search playlist and I am happy that I found exact pattern of updating low, mid and high for all the problems. But in the above problem is there a way to follow the same binary search pattern? I have seen many videos on youtube but everywhere they are updating high = mid and while condition is also different. It is like while(low
@iWontFakeIt
@iWontFakeIt Жыл бұрын
solve this using heap
@sairamyakamalibandla7667
@sairamyakamalibandla7667 Жыл бұрын
@@iWontFakeIt yes but there is binary search solution for thi as well
@sekhsamim2038
@sekhsamim2038 Жыл бұрын
Sir please add videos for linked list 😄
@worldtop_3
@worldtop_3 Жыл бұрын
Sir please upload strings lectures❤❤🎉❤❤
@lohithkadiyala8650
@lohithkadiyala8650 Жыл бұрын
Hey striver! Could please add leetcode problem 2790 to the binary search playlist and explain
@hardikpatel352
@hardikpatel352 2 ай бұрын
understood
@shreyanshtiwari6530
@shreyanshtiwari6530 11 ай бұрын
Sir what do you suggest if i am able to solve question from your sheet after looking at some part of videos or some discussion section of leetcode i mean i am not able to solve new questions by myself but after learning i am able to solve thosr types . So i was just wondering whether its right to look up at the solutions and learn from it or should give more time to solve questions by myself only ? Its a honest question i wish you can answer.
@sanjana6931
@sanjana6931 6 ай бұрын
same case with me...i think we should just solve more and more problems(by looking at solution) until we get used to the pattern of solving the questions!
@tanujain2605
@tanujain2605 Жыл бұрын
Bhaiya , convex hull algo par bhi video banao na
Understanding B-Trees: The Data Structure Behind Modern Databases
12:39
ВОДА В СОЛО
00:20
⚡️КАН АНДРЕЙ⚡️
Рет қаралды 30 МЛН
What it feels like cleaning up after a toddler.
00:40
Daniel LaBelle
Рет қаралды 82 МЛН
Nastya and SeanDoesMagic
00:16
Nastya
Рет қаралды 34 МЛН
Leetcode 46. Permutations : Introduction to backtracking
10:06
ComputerBread
Рет қаралды 90 М.
The moment we stopped understanding AI [AlexNet]
17:38
Welch Labs
Рет қаралды 811 М.
The $64M Race to Save the Eiffel Tower
12:46
The B1M
Рет қаралды 120 М.
The $2.1 Billion McDonald's Machine
10:35
fern
Рет қаралды 886 М.
Nature's Incredible ROTATING MOTOR (It’s Electric!) - Smarter Every Day 300
29:37
BS-17. Aggressive Cows | Binary Search Hard
26:44
take U forward
Рет қаралды 133 М.
How Venice Was Built On Water
9:28
Primal Space
Рет қаралды 41 М.
BS 19. Painter's Partition and Split Array - Largest Sum
11:20
take U forward
Рет қаралды 87 М.
ВОДА В СОЛО
00:20
⚡️КАН АНДРЕЙ⚡️
Рет қаралды 30 МЛН