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

Поділитися
Вставка
  • Опубліковано 28 лис 2024

КОМЕНТАРІ • 333

  • @takeUforward
    @takeUforward  Рік тому +93

    My bad, a small correction in the code:
    if((arr[i] - arr[i-1]) == (dist * numberInBetween)) {
    numberInBetween--;
    }
    1 == (2 * 0.5)

    • @Gamingnoobop
      @Gamingnoobop Рік тому +4

      bhai gfg ki link striver A2Z me add karo plz striver sheet is incomplete without gfg

    • @parthibchowdhury5558
      @parthibchowdhury5558 Рік тому +4

      I am confused.. how it is passing all the test cases then? By the way, Great Explanation love it😇

    • @harshitshukla1974
      @harshitshukla1974 Рік тому +2

      @@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 Рік тому +1

      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 Рік тому +1

      if(fmod((long double)(arr[i+1]-arr[i]),mid)==0) numberInBetween--;
      modulus work only in case of int so fmod

  • @visheshupadhyay1774
    @visheshupadhyay1774 10 місяців тому +123

    Striver is trying his very best to explain but the problem itself is very complex. Hats off bro...

  • @zaidwani1473
    @zaidwani1473 9 місяців тому +23

    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.

  • @sleepypanda7172
    @sleepypanda7172 Рік тому +94

    What a noble man. May he achieve all the success that he wants

  • @habeeblaimusa4466
    @habeeblaimusa4466 Рік тому +77

    Guys those of you saying use low

    • @infinityzero2321
      @infinityzero2321 Рік тому +5

      I think all almost all of them😅

    • @ganjinaveen7338
      @ganjinaveen7338 Рік тому +1

      @@infinityzero2321 yes bro

    • @GeneralistDev
      @GeneralistDev Рік тому +8

      please explain here only, I don't have time to go through whole playlist

    • @farazahmed7
      @farazahmed7 Рік тому

      @@GeneralistDev nhi bateynege poora dekh

    • @arunm619
      @arunm619 4 місяці тому +3

      @@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 Рік тому +36

    Sir please continue the series ...a lot of students are waiting eagerly for your videos .

  • @stith_pragya
    @stith_pragya 9 місяців тому +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..........🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻

  • @Shunya_Advait
    @Shunya_Advait Рік тому +13

    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.

  • @rohitsai806
    @rohitsai806 Рік тому +12

    Hard problem to absorb...! Kudos to your efforts, hats off Striver for your dedication

  • @avinashkumar3116
    @avinashkumar3116 3 місяці тому +1

    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 🫡

  • @avinashkumar3116
    @avinashkumar3116 3 місяці тому +2

    Not only Indian programming community but also the entire world programming community is in your debt Sir.

  • @stith_pragya
    @stith_pragya 9 місяців тому +4

    UNDERSTOOD...........Thank You So Much for this wonderful video..............🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻

  • @rohithalder7546
    @rohithalder7546 19 днів тому

    i'm cooked enough bro !!!!!!!!!!!!!!!!!!! hat's of to raj !!! he has tried his best to explain this .

  • @Entertainmentexe
    @Entertainmentexe Рік тому +2

    The best DSA course on the Internet

  • @himanshuranjan8344
    @himanshuranjan8344 Рік тому +12

    Effort level:- Inspirational 🏆

  • @i_m_phoenix87
    @i_m_phoenix87 Рік тому +4

    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

  • @sujalgupta6100
    @sujalgupta6100 6 місяців тому +3

    I would rather fail interview than trying this binary search solution
    took me 3 hours to make through this video

  • @yashpandey7
    @yashpandey7 17 днів тому

    Understood but a revision is needed to recall the approach of it. Thank you for the explanation, Raj bhiya .

  • @nptel1punith929
    @nptel1punith929 3 місяці тому

    not missing a single intuition, even if video length goes high, hats off bro..🔥🔥

  • @RaginiGupta-q1v
    @RaginiGupta-q1v 6 днів тому

    I can never fully express my gratitude for your efforts, Striver Bhaiya. Your explanations are consistently unparalleled and truly THE BEST!

  • @SarthakKumar
    @SarthakKumar Рік тому +1

    Dedication, Made Respect to him!! GIving a complete insight on the topic is just insane and very few people do it!

  • @-RAJSINGH
    @-RAJSINGH 4 місяці тому +1

    Best explanation! this was my first hard problem, but you made it so easy to understand. Hats off bhaiya!!!!

  • @SitaRam-m1i
    @SitaRam-m1i Місяць тому +2

    Bhaiya,I solved this question on my own(but for not a double case as in question i just done the question if it completely considering everything in integers......but the intution remained same for it too but with the change of dealing with float/double values.....)but it still boosted my confidence.....thank u bhaiya....i don't say i have improved 1000 times and i can solve any level of question on BS but i am improving with each video and maybe at a point i can solve questions as easy as u do....

    • @kurma.4932
      @kurma.4932 2 дні тому

      ssup bro, can i dm you?
      i just started and need some guidance

  • @apmotivationakashparmar722
    @apmotivationakashparmar722 3 місяці тому +1

    Striver is excellent to teach hard concept in a easiest way.

  • @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.

  • @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!!

  • @NonameNoname-f2t
    @NonameNoname-f2t 9 місяців тому +1

    sir ek hi dil hai kitne baar jeetoge ❣

  • @DR-mq1le
    @DR-mq1le Рік тому +3

    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 :)

  • @Gaurav-vl6ym
    @Gaurav-vl6ym Рік тому

    no one explains better than you ,thank you

  • @adityaraj402
    @adityaraj402 5 місяців тому

    His efforts>>>>

  • @harshilpatel3205
    @harshilpatel3205 9 місяців тому +1

    Hats off to your hardwork brother 🤍🫡

  • @kabirkapoor9149
    @kabirkapoor9149 Рік тому +8

    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?

  • @mohitsingh13
    @mohitsingh13 3 місяці тому

    Understood ❤ (1st and 2nd Approach)

  • @nookalareshwanth1785
    @nookalareshwanth1785 10 місяців тому +2

    This surely is an amazing problem

  • @neemaparnami8604
    @neemaparnami8604 5 місяців тому

    Can't thank you enough for this amazing content!! Explained so perfectly!! Thank you Striver for this course!!

  • @devils9844
    @devils9844 Рік тому +6

    Why are the videos not coming? please make a video regarding when the future videos will be released. I am very excited.

  • @niharbastia5740
    @niharbastia5740 Рік тому +4

    Amazing explanation so far🔥

  • @yaminireddy3321
    @yaminireddy3321 4 місяці тому

    Thank You Striver for the best explaination

  • @cinime
    @cinime Рік тому +2

    Understood! Super amazing explanation as always, thank you very much for your effort!!

  • @harshitjaiswal9439
    @harshitjaiswal9439 10 місяців тому

    Amazing! Dedication is super! Thank you Striver!

  • @apoorvasingh5702
    @apoorvasingh5702 6 місяців тому

    Thank you for explaining this difficult question so brilliantly.

  • @harshitpatil6138
    @harshitpatil6138 9 місяців тому

    Very well understood all three approaches specially priority queue one method

  • @bhoopendrasingh5832
    @bhoopendrasingh5832 8 місяців тому

    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

  • @preetisahani5054
    @preetisahani5054 Рік тому +1

    Awesome explanation. still trying to absorb last approach

  • @stith_pragya
    @stith_pragya 9 місяців тому

    ❗❗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🙏🏻🙏🏻

  • @Dontpushyour_luck
    @Dontpushyour_luck Рік тому +1

    did this question even before watching video. you taught binary search so good that I was able to do it so easily

  • @ambaradhikari7425
    @ambaradhikari7425 Рік тому +5

    Good explanation, please start string then linkedlist, also please add gfg links

  • @someshsunar4166
    @someshsunar4166 7 місяців тому

    Great Approach. Really loved the explanation. You made such an hard question easy to understand. Thanks❤❤

  • @madhabtripathy8691
    @madhabtripathy8691 9 місяців тому

    From Bruteforce -> better -> optimal. It was really hard question in BS. But anyways Thank You Striver for best explanation.

  • @maaz.i7
    @maaz.i7 Місяць тому

    It's actually very interesting problem

  • @heavenlyway5824
    @heavenlyway5824 Рік тому +16

    I appreciate everything you're doing. However, my only suggestion is, can you keep dark mode while writing code.

  • @hiteshpanchal5239
    @hiteshpanchal5239 Рік тому +4

    Striver bhai plzz start string series i am waiting for it.... ❤️❤️❤️

  • @factsworlda2k547
    @factsworlda2k547 2 місяці тому

    awesome striver !
    i have understand solution 2 and something something solution 3. you are pro God ❤❤

  • @valavalalohitkumar1348
    @valavalalohitkumar1348 Рік тому

    UnderStood Striver, and that's awesome. Thanks for making this

  • @beinginnit
    @beinginnit Рік тому +1

    Thank you so much Striver.Loved it.💖

  • @b_01_aditidonode43
    @b_01_aditidonode43 10 місяців тому

    hats off to your efforts sir, very well explained

  • @Bhalu-kl7sq
    @Bhalu-kl7sq 4 місяці тому

    maybe high have to watch again after sometime awesome video

  • @hashcodez757
    @hashcodez757 9 місяців тому

    last wali ne dimaag hila daala bhai!!

  • @vrushabhjoshi3155
    @vrushabhjoshi3155 4 місяці тому

    Hats off to your hard work 🫡

  • @shatwikshankar05
    @shatwikshankar05 Рік тому +3

    Absolutely loving your SDE sheet ….please just make a video on Rabin Karp algo and KMP algo…thoda bouncer jara hai uska concepts.

  • @hazarath6904
    @hazarath6904 5 місяців тому +1

    True to your name, Striver.

  • @onepercentswe
    @onepercentswe 6 місяців тому

    private int noOfStationsRequired(int[] stations, double dist) {
    int cnt = 0;
    for(int i=0; i

  • @sid3900
    @sid3900 2 місяці тому +1

    watching this while I'm drunk ...great watch

  • @yoyobaby2227
    @yoyobaby2227 3 місяці тому

    Striver, you are my DRIVER💞

  • @prasenjitsutradhar3368
    @prasenjitsutradhar3368 Місяць тому +1

    58:34 "If the interviewer doesn't agrees on that", ...................then tell him "bhar mai jao!"

  • @shantipriya370
    @shantipriya370 11 місяців тому

    just wow.. u really inspire me sir..

  • @EngineerStrange
    @EngineerStrange 6 місяців тому

    Hats off to the explanation. Awesome work sir

  • @sdsingh3577
    @sdsingh3577 Рік тому +12

    Plz bhaiya upload more and more videos as soon as possible......plz bhaiya

    • @Daddy30011
      @Daddy30011 Рік тому +5

      Th ode question khud se bhi try kiya karo 🥲

    • @sdsingh3577
      @sdsingh3577 Рік тому

      @@Daddy30011 not question bro.....I say introduction tutorial of pointer and some other

  • @jashhinger442
    @jashhinger442 11 місяців тому

    Striver you are GOD!!!

  • @knownforunknowns
    @knownforunknowns 22 дні тому

    Love u bhaiya .....Thank u for hard work ♥

  • @knowledgedoctor3849
    @knowledgedoctor3849 Рік тому +2

    Stack & Queue Series Please Also Linked List.

  • @shahidullahmuffakir668
    @shahidullahmuffakir668 5 місяців тому

    I directly taught of BS solution, but loved you pq solution.

  • @subhrajsingh
    @subhrajsingh 9 місяців тому

    best video till date

  • @abdussalam-4836
    @abdussalam-4836 4 місяці тому

    A small improvement in brute force is u don't need to have a howmany vector u can use the pair in pq

  • @HARSHKAJALKHANEIIIIIIII
    @HARSHKAJALKHANEIIIIIIII 6 місяців тому

    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.

  • @JayPatel-sn7it
    @JayPatel-sn7it Рік тому +5

    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 🥺

  • @Freefire-hp4zz
    @Freefire-hp4zz Рік тому +5

    Bhai Will You Continue To Upload DSA COURSE VIDEOS AFTER BINARY SEARCH??? PLEASE UPLOAD STRING PLAYLIST BHAI

  • @JIGARSINGTHAKOR-yy6qp
    @JIGARSINGTHAKOR-yy6qp 7 місяців тому +2

    if Interviewer is asking for BS just say i'm done and move on

  • @jayant1407
    @jayant1407 Рік тому +17

    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

  • @yugal8627
    @yugal8627 Рік тому +5

    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  Рік тому +37

      I said repeatedly, we solve all the problems with while(low

  • @sauravchandra10
    @sauravchandra10 Рік тому +1

    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

  • @playwithlinux
    @playwithlinux 5 місяців тому

    Amazing content bro... Love you so much

  • @arghyadeepbhowmick2248
    @arghyadeepbhowmick2248 Рік тому

    Great video sir! Hats off!

  • @azmirvali6205
    @azmirvali6205 Рік тому +2

    Bayya please make sure in SDE sheet the you tube video should be play in other page when we click to watch

  • @adityagarg71
    @adityagarg71 3 місяці тому

    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.

  • @sidharthsharma341
    @sidharthsharma341 Рік тому +1

    bhaiya ....some game changer was coming on 22nd july

  • @sanjayp.m7008
    @sanjayp.m7008 Рік тому +2

    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

  • @sunilpatidar8609
    @sunilpatidar8609 Рік тому +2

    bhai can yu tell how many month yu will take complete this course actually i am new this chanel approx 3 month

  • @shreyanshtiwari6530
    @shreyanshtiwari6530 Рік тому +3

    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 10 місяців тому

      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!

  • @atharva..deshmukh
    @atharva..deshmukh 4 місяці тому

    Very nice explanation

  • @kritikasingh4876
    @kritikasingh4876 Рік тому +4

    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

  • @girikgarg8
    @girikgarg8 Рік тому

    Done! Nicely explained

  • @ayushmamgain9040
    @ayushmamgain9040 3 місяці тому

    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.

  • @ArnabBhadra02
    @ArnabBhadra02 Рік тому +1

    please striver post the next videos asap we are eagerly waiting for ur vds please, placement start ho gya please complete the series

  • @brahmleenkaur8284
    @brahmleenkaur8284 Рік тому +5

    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

  • @amanupadhyay8628
    @amanupadhyay8628 Рік тому

    you are great bhaiya love you❤

  • @prabhatmishras421
    @prabhatmishras421 4 місяці тому

    Madddd Respect man♥♥

  • @oyeesharme
    @oyeesharme 3 місяці тому

    bhaut hard bhaut hard

  • @AKASHKUMAR-li7li
    @AKASHKUMAR-li7li 8 місяців тому

    You are just awesome man👍

  • @TheProblemSolvers38
    @TheProblemSolvers38 3 місяці тому

    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).

    • @delta_mohit
      @delta_mohit Місяць тому

      because we only wants the distance to check whether it is maximum or not. Since the all the distances in that particular range will be equal so taking only one distance is enough.