Тёмный

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

take U forward
Подписаться 671 тыс.
Просмотров 132 тыс.
50% 1

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/take...
0:00 Introduction of Course

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

 

15 сен 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 317   
@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 7 месяцев назад
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 9 месяцев назад
he had already achieved it
@AyushMishra-b8w
@AyushMishra-b8w 5 месяцев назад
@@sohamgaikwad15 still more go
@kiranmoura2974
@kiranmoura2974 Год назад
Sir please continue the series ...a lot of students are waiting eagerly for your videos .
@zaidwani1473
@zaidwani1473 7 месяцев назад
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.
@habeeblaimusa4466
@habeeblaimusa4466 Год назад
Guys those of you saying use low
@infinityzero2321
@infinityzero2321 Год назад
I think all almost all of them😅
@ganjinaveen7338
@ganjinaveen7338 Год назад
@@infinityzero2321 yes bro
@GeneralistDev
@GeneralistDev Год назад
please explain here only, I don't have time to go through whole playlist
@farazahmed7
@farazahmed7 11 месяцев назад
@@GeneralistDev nhi bateynege poora dekh
@arunm619
@arunm619 2 месяца назад
@@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.
@Shunya_Advait
@Shunya_Advait Год назад
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.
@stith_pragya
@stith_pragya 7 месяцев назад
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..........🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻
@rohitsai806
@rohitsai806 11 месяцев назад
Hard problem to absorb...! Kudos to your efforts, hats off Striver for your dedication
@himanshuranjan8344
@himanshuranjan8344 Год назад
Effort level:- Inspirational 🏆
@i_m_phoenix87
@i_m_phoenix87 Год назад
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
@stith_pragya
@stith_pragya 7 месяцев назад
UNDERSTOOD...........Thank You So Much for this wonderful video..............🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻
@avinashkumar3116
@avinashkumar3116 Месяц назад
Agar Bharat phir se vishwa guru banta h to Bharat ke us mahan vishwavidyalay me Data Structures and Algorithms ki neev aap hi rakhenge. Aap hi honge DSA ke sabse mahaan teacher. Salute 🫡
@SarthakKumar
@SarthakKumar Год назад
Dedication, Made Respect to him!! GIving a complete insight on the topic is just insane and very few people do it!
@nptel1punith929
@nptel1punith929 15 дней назад
not missing a single intuition, even if video length goes high, hats off bro..🔥🔥
@-RAJSINGH
@-RAJSINGH Месяц назад
Best explanation! this was my first hard problem, but you made it so easy to understand. Hats off bhaiya!!!!
@Entertainmentexe
@Entertainmentexe Год назад
The best DSA course on the Internet
@yashshetty7326
@yashshetty7326 Год назад
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!!
@sujalgupta6100
@sujalgupta6100 4 месяца назад
I would rather fail interview than trying this binary search solution took me 3 hours to make through this video
@avinashkumar3116
@avinashkumar3116 Месяц назад
Not only Indian programming community but also the entire world programming community is in your debt Sir.
@neemaparnami8604
@neemaparnami8604 3 месяца назад
Can't thank you enough for this amazing content!! Explained so perfectly!! Thank you Striver for this course!!
@cinime
@cinime Год назад
Understood! Super amazing explanation as always, thank you very much for your effort!!
@factsworlda2k547
@factsworlda2k547 День назад
awesome striver ! i have understand solution 2 and something something solution 3. you are pro God ❤❤
@someshsunar4166
@someshsunar4166 4 месяца назад
Great Approach. Really loved the explanation. You made such an hard question easy to understand. Thanks❤❤
@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.
@Dontpushyour_luck
@Dontpushyour_luck 11 месяцев назад
did this question even before watching video. you taught binary search so good that I was able to do it so easily
@kabirkapoor9149
@kabirkapoor9149 Год назад
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 Год назад
final year aswell?
@apmotivationakashparmar722
@apmotivationakashparmar722 20 дней назад
Striver is excellent to teach hard concept in a easiest way.
@DR-mq1le
@DR-mq1le Год назад
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 :)
@apoorvasingh5702
@apoorvasingh5702 4 месяца назад
Thank you for explaining this difficult question so brilliantly.
@ambaradhikari7425
@ambaradhikari7425 Год назад
Good explanation, please start string then linkedlist, also please add gfg links
@heavenlyway5824
@heavenlyway5824 Год назад
I appreciate everything you're doing. However, my only suggestion is, can you keep dark mode while writing code.
@devils9844
@devils9844 Год назад
Why are the videos not coming? please make a video regarding when the future videos will be released. I am very excited.
@hiteshpanchal5239
@hiteshpanchal5239 Год назад
Striver bhai plzz start string series i am waiting for it.... ❤️❤️❤️
@harshitpatil6138
@harshitpatil6138 7 месяцев назад
Very well understood all three approaches specially priority queue one method
@niharbastia5740
@niharbastia5740 Год назад
Amazing explanation so far🔥
@preetisahani5054
@preetisahani5054 11 месяцев назад
Awesome explanation. still trying to absorb last approach
@harshilpatel3205
@harshilpatel3205 7 месяцев назад
Hats off to your hardwork brother 🤍🫡
@bhoopendrasingh5832
@bhoopendrasingh5832 5 месяцев назад
Before Optimizing this with BS It was preety Easy to Solve but When it comes to furthur optimize, the question changes it's difficulty to Hard Nicely Explained Thank You Bhai
@madhabtripathy8691
@madhabtripathy8691 6 месяцев назад
From Bruteforce -> better -> optimal. It was really hard question in BS. But anyways Thank You Striver for best explanation.
@nookalareshwanth1785
@nookalareshwanth1785 8 месяцев назад
This surely is an amazing problem
@TheProblemSolvers38
@TheProblemSolvers38 17 дней назад
At 37:20, should we only need to insert only one part of the distance or all the parts of the distance, I mean, if there are gas stations at 1 and 13, when we place a new gas station at 7, we will have two distances now, right? 1 to 7 and 7 to 13. We need to insert both distances right. But we are only inserting one of them(Into the Priority Queue).
@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
@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 Год назад
Yesss please Striver
@yaminireddy3321
@yaminireddy3321 2 месяца назад
Thank You Striver for the best explaination
@Bhalu-kl7sq
@Bhalu-kl7sq Месяц назад
maybe high have to watch again after sometime awesome video
@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 Год назад
Where can I find it ?
@shatwikshankar05
@shatwikshankar05 Год назад
@@grette4156 search on google-striver sde sheet
@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
@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
@harshitjaiswal9439
@harshitjaiswal9439 8 месяцев назад
Amazing! Dedication is super! Thank you Striver!
@EngineerStrange
@EngineerStrange 3 месяца назад
Hats off to the explanation. Awesome work sir
@valavalalohitkumar1348
@valavalalohitkumar1348 Год назад
UnderStood Striver, and that's awesome. Thanks for making this
@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 🥺
@adityagarg71
@adityagarg71 16 дней назад
If we will make ans variable and try to return it as answer. It will not work in cases where the high itself is the answer , because the mid will never be equal to high , hence the no. of stations function will never return true , hence ans variable will never change . It will just return the value with which it was initialised.
@mohitsingh13
@mohitsingh13 Месяц назад
Understood ❤ (1st and 2nd Approach)
@beinginnit
@beinginnit Год назад
Thank you so much Striver.Loved it.💖
@Gaurav-vl6ym
@Gaurav-vl6ym 10 месяцев назад
no one explains better than you ,thank you
@b_01_aditidonode43
@b_01_aditidonode43 7 месяцев назад
hats off to your efforts sir, very well explained
@abdussalam-4836
@abdussalam-4836 Месяц назад
A small improvement in brute force is u don't need to have a howmany vector u can use the pair in pq
@knowledgedoctor3849
@knowledgedoctor3849 Год назад
Stack & Queue Series Please Also Linked List.
@HARSHKAJALKHANEIIIIIIII
@HARSHKAJALKHANEIIIIIIII 3 месяца назад
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.
@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
@adityaraj402
@adityaraj402 2 месяца назад
His efforts>>>>
@yoyobaby2227
@yoyobaby2227 Месяц назад
Striver, you are my DRIVER💞
@azmirvali6205
@azmirvali6205 Год назад
Bayya please make sure in SDE sheet the you tube video should be play in other page when we click to watch
@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
@ayushmamgain9040
@ayushmamgain9040 Месяц назад
at 36:50 line number 13, shouldn't it be long double newSecLen = inDiff / (long double howMany[secInd]); There is no need for a +1 because we already incremented howMany[secInd] at line number 11.
@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
@onepercentswe
@onepercentswe 4 месяца назад
private int noOfStationsRequired(int[] stations, double dist) { int cnt = 0; for(int i=0; i
@NonameNoname-f2t
@NonameNoname-f2t 6 месяцев назад
sir ek hi dil hai kitne baar jeetoge ❣
@sunilpatidar8609
@sunilpatidar8609 Год назад
bhai can yu tell how many month yu will take complete this course actually i am new this chanel approx 3 month
@stith_pragya
@stith_pragya 6 месяцев назад
❗❗FOR THOSE who were not able to get why Striver has written the following line in the last approach: if((arr[i] - arr[i - 1]) / dist) == numberInBetween * dist) THIS IS A MISTAKE IT SHOULD BE: if((arr[i] - arr[i - 1]) == numberInBetween * dist) i.e if a = b / c, then for the confirmation you will do -> b == a * c, not b / c == a * c. Thanks🙏🏻🙏🏻
@brahmleenkaur8284
@brahmleenkaur8284 Год назад
hi I have solved your a to z sheet and it is a great help but recently you have removed the gfg links and I usually revise from the code that i have solved in the ide. please add the gfg links as well and do not remove the leetcode links. thanks
@kumarshivam3661
@kumarshivam3661 Год назад
Bro can you send your wsp or tg account
@shahidullahmuffakir668
@shahidullahmuffakir668 2 месяца назад
I directly taught of BS solution, but loved you pq solution.
@sid3900
@sid3900 2 дня назад
watching this while I'm drunk ...great watch
@vrushabhjoshi3155
@vrushabhjoshi3155 2 месяца назад
Hats off to your hard work 🫡
@arnab027
@arnab027 Год назад
please striver post the next videos asap we are eagerly waiting for ur vds please, placement start ho gya please complete the series
@shreyanshtiwari6530
@shreyanshtiwari6530 Год назад
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 8 месяцев назад
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!
@project_eth
@project_eth 2 месяца назад
holy sh*t this question was hard to understand, but seriously man what an explanation!
@shantipriya370
@shantipriya370 9 месяцев назад
just wow.. u really inspire me sir..
@devils9844
@devils9844 Год назад
I did not understood the part where we check if it is completely divisible, so we reduce 1, i can't understand the code part for this condition
@takeUforward
@takeUforward Год назад
My bad, should have been the below. if((arr[i] - arr[i-1]) == (dist * numberInBetween)) { numberInBetween--; } 1 == (2 * 0.5)
@infinityzero2321
@infinityzero2321 Год назад
Hey, Striver I appreciate your efforts and the quality content you are providing for free. I have been following your a2z dsa sheet for a month now and had been solving the questions diligently. I know that coding ninjas is a very good platform but would like to request you to please add a new section of gfg links also as i had did a lot of them on gfg and since all of ot is gone now it is difficult for many people like to go back and search links for those gfg questions. Thank and best wishes
@joydeepdas29
@joydeepdas29 Год назад
Raj bhaiya I also have the same request. If you can look into this matter it will be very much helpful. I used to solve a lot of questions following the sheets (all of them were on gfg) and due to personal reasons I was not regular and stopped. But I am starting again (my placement season also coming) and this change is very sudden. So please help with this. Thank you 😊.
@mano_003
@mano_003 Год назад
If u want gfg link for the problem just reload the website and press esc button b4 it gets reload.
@joydeepdas29
@joydeepdas29 Год назад
@@mano_003 Thank you very much. This trick really worked. Now I can again start the sheet with ease ❤️. Really appreciate your help 😄.
@infinityzero2321
@infinityzero2321 Год назад
@@mano_003 thank you . this helped a lot .
@shameekagarwal4872
@shameekagarwal4872 7 месяцев назад
sorry, i cudnt catch the time complexity of the binary search solution. is it O(N + (log(high * 10^6) * N))?
@sidharthsharma341
@sidharthsharma341 Год назад
bhaiya ....some game changer was coming on 22nd july
@gagangandi4564
@gagangandi4564 Год назад
whats that
@playwithlinux
@playwithlinux 3 месяца назад
Amazing content bro... Love you so much
@riteshkumargupta4001
@riteshkumargupta4001 2 месяца назад
Great Explanations, but priority queue approach gets wrong n test3 at gfg
@JIGARSINGTHAKOR-yy6qp
@JIGARSINGTHAKOR-yy6qp 4 месяца назад
if Interviewer is asking for BS just say i'm done and move on
@hashcodez757
@hashcodez757 7 месяцев назад
last wali ne dimaag hila daala bhai!!
@worldtop_3
@worldtop_3 Год назад
Sir please upload strings lectures❤❤🎉❤❤
@JayPatel-sn7it
@JayPatel-sn7it Год назад
Striver's site is down...or it is internet issue of mine?
@leisuretime4198
@leisuretime4198 Год назад
Down hai
@leisuretime4198
@leisuretime4198 Год назад
Jldi shi ho jaye kl s issue aa rhe
@ris_colid325
@ris_colid325 11 месяцев назад
Can someone please explain why Take you forward code (in the website article based on striver's video) for this minimize max distance between gas stations problem(including the correction in pinned comment) passes all test cases in codestudio but gives wrong answer in Geeks for geeks?
@dhruvchopra26
@dhruvchopra26 8 месяцев назад
the question might be slightly different in terms of edge cases,nothing to worry about.
@sarathy3024
@sarathy3024 Год назад
@tuf I forgot my account password for loggin in the tuf website, I don't see any option to reset my password 😅 Can you please help me?
@kushalgupta2041
@kushalgupta2041 5 дней назад
could anyone explain this why at this condition if((arr[i] - arr[i-1])/dist == noInBetween*dist ) answer is submitted correct
@adityaagarwal4183
@adityaagarwal4183 2 месяца назад
Your priority queue solution does not get accepted on gfg...cant figure out why
@noon-nb5ed
@noon-nb5ed Год назад
Hey strive can your please add gfg links to A2Z sheet. (Can you people make this comment to reach striver)
@sarankumaar6009
@sarankumaar6009 Год назад
I disagree he is doing lot of effort for these videos. let him earn some money in return atleast.
@sekhsamim2038
@sekhsamim2038 Год назад
Sir please add videos for linked list 😄
@arghyadeepbhowmick2248
@arghyadeepbhowmick2248 11 месяцев назад
Great video sir! Hats off!
@atharva..deshmukh
@atharva..deshmukh 2 месяца назад
Very nice explanation
@girikgarg8
@girikgarg8 11 месяцев назад
Done! Nicely explained
Далее
Тарковский - гений
00:48
Просмотров 513 тыс.
BS-17. Aggressive Cows | Binary Search Hard
26:44
Просмотров 153 тыс.
Higher-Order Components Are Misunderstood In React
17:38
FASTEST Way To Learn Coding and ACTUALLY Get A Job
10:44
5 Math Skills Every Programmer Needs
9:08
Просмотров 1 млн
LeetCode is a JOKE with This ONE WEIRD TRICK
4:54
Просмотров 54 тыс.
Binary Search Algorithm - Computerphile
18:34
Просмотров 160 тыс.
Тарковский - гений
00:48
Просмотров 513 тыс.