Lecture14: Binary Search Interview Questions [Google, Amazon, Microsoft] || ProblemSet - 2

Поделиться
HTML-код
  • Опубликовано: 8 ноя 2024

Комментарии • 1,1 тыс.

  • @CodeHelp
    @CodeHelp  2 года назад +169

    Do make sure to visit Relevel: relvl.co/tv0v :-)

    • @BitsAndBytesAI
      @BitsAndBytesAI 2 года назад +5

      Bhiya scope of data science par ek video bano please

    • @BitsAndBytesAI
      @BitsAndBytesAI 2 года назад +4

      🔥🔥

    • @yashmanmode5727
      @yashmanmode5727 2 года назад +1

      bhaiya vo square root wale me Baar Baar SIGTERM output para hai kya cru

    • @swastikvasistha7488
      @swastikvasistha7488 2 года назад

      #love bahiya yeh code studio vala square root question ka code dedo usme kuch case big no vale submit krne pe fail ho rhe h

    • @rameshmalhotra9525
      @rameshmalhotra9525 2 года назад

      ruclips.net/video/tAQIKe0UGH4/видео.html

  • @ketangaikwad8617
    @ketangaikwad8617 2 года назад +117

    This is the best dsa series on RUclips!!!!!
    My request is to everyone who is reading this comment plz share this playlist with your juniors and friends. You can share with at least one friend.

    • @x-Aryan.32
      @x-Aryan.32 4 месяца назад +3

      chal bhai age gyan mt pe***

  • @zhrrBro
    @zhrrBro 2 года назад +17

    Another approach to find pivot in an array !!!
    int getpivot(int arr[],int n){
    int s = 0;
    int e = n-1;
    int mid = s + (e-s)/2;
    while(s

    • @L.Lawliet_1618
      @L.Lawliet_1618 2 месяца назад +2

      if mid is the pivoted element?

  • @AbdulWahab-jl4un
    @AbdulWahab-jl4un Год назад +10

    Bhaiyya aap OP ho pivot wala problem teen baar dekhne ke baad samjh aaya uske baaad toh chize easy kardiye aapne.Thanks bhaiyya having a teacher like you can get me a job in Google.❤❤❤

  • @amandwivedi976
    @amandwivedi976 2 года назад +58

    49:37
    "mujhe lag rha hai ki aapko bilkul smjh nhi aa rha",
    "mujhe pata hai aapko nhi aa rha "
    "tension na le ,"
    "mujhe pata lg gya aapko smjh nhi aa rha "
    VERY VERY ACURATE FOR ME AT THIS MOMENT
    mai shock ho gya laga aamne saamne padh rha hoon.......😊😊

    • @DeepakSharma-nq3ee
      @DeepakSharma-nq3ee 4 месяца назад +3

      bhai yehi likne ke liye aya tha scroll krta niche...these lines were Fr

  • @simpleexperiment42
    @simpleexperiment42 2 года назад +31

    Sir you deserve all good and wealth in this world, because you love other as yourself and you always help and support. You have been a great teacher, lecturer, and a Professor to me, and I fully enjoyed your lectures, you explained everything in detail

  • @b088mohdzaid5
    @b088mohdzaid5 2 года назад +33

    Difference of Love babbar and Aman dattarwal course is :-
    Aman dattarwal course made by FAANG people's and love babbar course made to crack FAANG

    • @gandharvmunjal
      @gandharvmunjal 2 года назад +7

      Do not forget that he has also worked in amazon for 2 years

  • @ishangrover1453
    @ishangrover1453 Год назад +7

    pivot you explain is other and array is sorted but in previous lecture you told us to solve a leetcode question 724 in which pivot means this-:
    The pivot index is the index where the sum of all the numbers strictly to the left of the index is equal to the sum of all the numbers strictly to the index's right.

    • @1hokage8
      @1hokage8 Год назад +1

      exactly..the one he used is for rotated array question

    • @sparrowgaming6151
      @sparrowgaming6151 5 дней назад

      exactly i don't know what type of pivot is in the video it not also work for any leetcode
      questions

    • @sparrowgaming6151
      @sparrowgaming6151 5 дней назад

      @@1hokage8 no not working

  • @lovishmittal4859
    @lovishmittal4859 2 года назад +36

    You deserves millions of subscribers for your hardwork bro. You are way better than code with Harry telusku etc etc. You explains everything twice no one even do it once properly. Hats off to you sir. Keep growing.❤️

  • @harshitaverma2695
    @harshitaverma2695 2 года назад +4

    Thank you so much bhaiya.. ye series bahut achchi hai jab maine dsa start kiya tha to normal sa question banane mai bhi ghanto lag jate the but abhi apki vajah se aaj maine 3 achche questions 40 min mai kar liye.. thank you so much... ab confidence bhi aa rha hai ki ho jayega dsa

    • @MohitNegi-r7d
      @MohitNegi-r7d 9 месяцев назад

      aapne yhi question 40 min mai kiye ki dusre que 40 min mai kiye

    • @MohitNegi-r7d
      @MohitNegi-r7d 9 месяцев назад

      please reply

  • @dharrsanamarnath7541
    @dharrsanamarnath7541 2 года назад +90

    Staying strong with you...14th lecture!
    No going back Babbar bro...
    I love the series till now.
    Especially the optimized way to find mid-value and also these binary search questions are making me think better. I'll comment in the next video. See you then!
    Regards,
    Dharrsan

    • @lalitsharma3137
      @lalitsharma3137 2 года назад

      placement hogyi?

    • @lalitsharma3137
      @lalitsharma3137 2 года назад

      placement hogyi?

    • @understanding-why
      @understanding-why 2 года назад +8

      @@lalitsharma3137 haa 5000 rupay mahina. maine hi internship di h isko

    • @paras_jain1312
      @paras_jain1312 Год назад +1

      @@understanding-why 😂😂

    • @arnobbaiga309
      @arnobbaiga309 Год назад

      can u tell me why comparision takes place in 15;40 _ as s=4 and end =4 while statement doesnt satisfy here

  • @bernardhackwell4410
    @bernardhackwell4410 2 года назад +28

    2:30 The way you use colors of Indian flag and explain concepts is soo satisfying. You are contributing a lot to India indirectly by making a big change in Education industry.

    • @arjunyadav-kt5jr
      @arjunyadav-kt5jr 2 года назад +6

      may be he didn't intend that!

    • @D6v1n9_karan
      @D6v1n9_karan Год назад

      @@arjunyadav-kt5jr

    • @Gurshxns
      @Gurshxns 5 месяцев назад +2

      padle bhai bharat sarkaar free ki naukri nahi degi....khud hi karna h jo karna h

  • @Nishad_Ranade1729
    @Nishad_Ranade1729 2 года назад +53

    Sir two suggestion ..... 1) First one is If possible you give topic time table that which topic you will teach in which day or date so all can atleast prepare the topic understand the topic by themselves and solve some problems related to topic ..... which helps to understand all points that you taught in video 2) And second one is you give all difficulty level question links ( generally medium and hard) and maximum problems of that topic that all can master the topic and solve any problem of that topic in all formats in interview or in CP, or in leetcode and all other platforms....

    • @rvishal528
      @rvishal528 2 года назад

      Yes✌️✌️✌️✌️✌️✌️✌️

    • @sjcreations2490
      @sjcreations2490 2 года назад

      I think it is not possible because love bhaiya search for topic and possible questions from that topic and make video accordingly. How can you expect that he can provide you dates before.

    • @Nishad_Ranade1729
      @Nishad_Ranade1729 2 года назад

      @@sjcreations2490 No sir ......I think he had some plan in mind what topics that he covered so what his plan related to topic covering , he should give and I am not saying that give 2 months plan day wise but my suggestion is atleast give weekly plan ........ and secondly I think bhaiyaa recorded the session few days before the session upload on RUclips.....

    • @abhinavmishra9323
      @abhinavmishra9323 2 года назад

      i just type the problem in google and leetcode in it and the first result is the leetcode problem. Hope this helps.

    • @rameshmalhotra9525
      @rameshmalhotra9525 2 года назад

      ruclips.net/video/tAQIKe0UGH4/видео.html

  • @rahulra9904
    @rahulra9904 11 месяцев назад +4

    the approach of finding the piovt element is correct and in most o fthe cases it will retrun the correct value, but in inputs like {11,13,15,17}, the pivot will move to index 3 but it is wrong, so aas per me logic we should declare a temp variable outside the loop value 0. after the loop is terminated we will compare the value of temp index with the start index value if the value of the start index is smaller we will return start else we will return temp.. this will help to find the piovt in all cases, whether the array is rotated or not..

  • @harshitsingh5832
    @harshitsingh5832 2 года назад +2

    in 15:47 start and end both pointing at 4, so the loop stop here only as in while condition (s

  • @rockinhitzz8682
    @rockinhitzz8682 Год назад +11

    31:40 Bhaiya At this timestamp of video , I would suggest try to start an array from [ 1 to n/2 ]. Reason is for any number n , square root of n is always smaller than n/2 ( Corollary Based on popular Theorem ).I don't remember the name of that theorem. This will slightly optimize an algorithm.
    Example : n = 36 ==> 6 < 18
    n = 81. ==> 9 < 40
    n = 625 ==> 25 < 312 and so on ..

    • @vikrantbhadouriya
      @vikrantbhadouriya Год назад

      yes brother, I searched about it and found that the one you mentioned is a corollary of the AM-GM inequality, it states:
      (m+1)/2 >= sqrt(m) (where m belongs to N)

    • @deepbhatia_1511
      @deepbhatia_1511 Год назад +3

      Hii.. This will be true for all numbers except 2... because sqroot of 2 is 1.414, which is greater than its half (1).
      Thanks.

    • @siddhantkotak6563
      @siddhantkotak6563 Год назад +2

      @@deepbhatia_1511 also it won't hold true for 3 as well, as root 3= 1.732 and 3/2=1.5 ....

  • @sudhanshusingh7200
    @sudhanshusingh7200 2 года назад +17

    It has been the best series so far on youtube. This series is really helping me to improve my thinking & logic building skills .
    Thank you bhaiya...keep it up.

    • @yashgupta6574
      @yashgupta6574 Год назад +1

      is it correct that pivot element is min or max element of an array?

    • @alphaomega3749
      @alphaomega3749 Год назад

      @@yashgupta6574 yes bcoz it is a sorted array so either first element or last element bcome pivoted element so it,s obvious that it would be max or min

  • @govindsuryavanshi6653
    @govindsuryavanshi6653 Год назад +11

    First I have completed all DSA series and now conclude this is Greatest ever DSA series to exist on youtube or paid courses. Your contribution will be remembered. You're God of DSA for us🙇‍♂

    • @ms_peace01
      @ms_peace01 Год назад

      Congratulations for the completion bro 🎉❤

    • @ayushuniyal2586
      @ayushuniyal2586 8 месяцев назад

      are you placed

  • @raunakbaliyan9918
    @raunakbaliyan9918 5 месяцев назад +2

    in pivot element, if the array is not rotated in edge case then it will return last index that is wrong so we have to compare with last element not first element in array,
    int findMin(vector& nums) {
    int start = 0;
    int end = nums.size()-1;
    int mid = start+(end-start)/2;
    while(startnums[nums.size()-1]){
    start = mid+1;
    }else{
    end = mid;
    }
    mid = start+(end-start)/2;
    }
    return start
    }

    • @Yashkyk
      @Yashkyk 4 месяца назад

      If it is not rotated then use binary search algorithm since it is increasing Order

  • @puneet4419
    @puneet4419 2 года назад +16

    We all are with you bhaiya. please be constant till the end. Your way of teaching is excellent.

  • @primeop8576
    @primeop8576 Год назад +2

    if anyone finding 11:23 answer here it is
    class Solution {
    public:
    int pivotIndex(vector& nums) {
    // accumulate is a stl which is used to addition of array
    int rs=accumulate(nums.begin(),nums.end(),0);
    int ls=0;
    for(int i=0;i

  • @Happiness-BellaAndCookie
    @Happiness-BellaAndCookie Год назад +7

    I have watched many DSA series but your course is one of the best series that I have watched till now, thank you so much for putting so much of efforts for us. I wish you keep growing in every aspect of your life ... :),
    1 question, does anyone came to know about the 2nd and 3rd approach of Finding an element in rotated sorted array?

    • @swayamtiwari8194
      @swayamtiwari8194 11 месяцев назад

      well the second approach can be done by using the if condition nums[start]

  • @sum_itt20
    @sum_itt20 2 года назад +17

    ATTENDANCE MARKED, VISITED RELEVEL, MADE NOTES, SOLVED QUESTIONS, LIKED THE VIDEO, EXITED WITH A SMILE.

  • @devanshusahoo
    @devanshusahoo 2 года назад +10

    Truly Great series sir, You have truly helped me overcome my fear of DSA.
    Thank You very Much.

  • @mahajan2244
    @mahajan2244 2 года назад +1

    apke ka course bhai sab courses s unique is liye h kyuki apne har topic p bohot sare question karaye h , jo kisi ne nhi karaye , best than paid course

  • @alishachhabra5910
    @alishachhabra5910 Год назад +8

    BEST TEACHER AWARD GOES TO YOU BHAIYA😇

  • @JamesHalpert8555
    @JamesHalpert8555 2 года назад +9

    Explaining T.C. and S.C. of all the problems after soln. will be very helpful

  • @akshaysingh548
    @akshaysingh548 2 года назад +25

    The code that he has explained for pivot index only works when array is rotated at least once, if array is not rotated or else it is rotated n times (where n is arr.size() - 1) it will give incorrect answer on leetcode question 153.
    And to fix this we can write this on very top of our function: if(nums[0]

    • @kamleshrawat5809
      @kamleshrawat5809 Год назад +5

      we can also use this
      int start=0,end=size-1,mid;
      while(startarr[end])
      start=mid+1;
      else if(arr[mid]

    • @amanMAYHEM
      @amanMAYHEM 11 месяцев назад

      faced this exact problem. thanks.

    • @Sk10696
      @Sk10696 10 месяцев назад

      the code for this problem( search in rotated sort array) given on gihub gives compilation error...is it with everyone?

    • @anishtripathi3800
      @anishtripathi3800 5 месяцев назад

      For that you can use the following condition in the beginning itself:-
      if(arr[0]

    • @SumitRathore-k3e
      @SumitRathore-k3e 4 месяца назад +1

      TLE aarha

  • @kishanpayadi8168
    @kishanpayadi8168 2 года назад +7

    A better approach for the second question.
    according to you, the process/flow chart is-
    1- finding pivot.
    2- apply that target formula and find the portion of the monotonic function.
    3-Then apply Binary search to find the index value.
    according to me.
    1- if(key>=arr[0]){
    //apply binary in the first segment
    }
    else {
    //apply binary in second segment
    }
    I am not an expert on time complexity, just have seen your previous video.
    but for your approach time complexity should be
    1 O(log2^n)+O(log2^n)
    and for my approach, it should be O(log2^n)
    P.s I've just started DSA, so correct me if I am wrong.

    • @kishanpayadi8168
      @kishanpayadi8168 2 года назад +5

      Edit- I found my mistake.
      How can I apply binary search in the first or second segment if I dont know the pivot element(i.e. start of second segment and end of the first segment.)

    • @RohitKumar-zd2hu
      @RohitKumar-zd2hu 2 года назад +1

      Exactly you can not apply binary search in an array without knowing 1st and last index of array

    • @adarshtiwari2727
      @adarshtiwari2727 2 года назад +1

      // THis is what i did and it was accepted in leetcode 33
      int search(vector& nums, int target) {
      int s=0;
      int e=nums.size()-1;
      int mid=s+(e-s)/2;
      while(s=nums[0]){
      if(nums[mid]>target)
      e=mid-1;
      else if(nums[mid]>=nums[0])
      s=mid+1;
      else
      e=mid-1;
      }
      else{
      if(nums[mid]=nums[0])
      s=mid+1;
      else
      e=mid-1;
      }
      mid=s+(e-s)/2;
      }
      return -1;
      }

    • @zisunvlogs2002
      @zisunvlogs2002 2 года назад

      @@adarshtiwari2727 brother could you please explain me the Algo ??i can't solve it in leetcode

    • @arnobbaiga309
      @arnobbaiga309 Год назад

      can u tell me why comparision takes place in 15;40 _ as s=4 and end =4 while statement doesnt satisfy here

  • @poojatajane9660
    @poojatajane9660 2 года назад +33

    Present sir.... Your student josh is always high for the exciting class of DSA#lovebabbar

  • @vanshhans21
    @vanshhans21 2 месяца назад +2

    ye jo first question hai pivot element wala usme hum arr[0] se na compare keke balki arr[end] se kare to jada best hoga kyuki hume nhi pta hota ki sorted array kitni baar rotate kia gya hai kya pata vo rotate hoke sirf sorted hi hogya ho jaise ki {11,12,13,14,15} ye array rotate hoke yhi ban gya to arr[0] se hamara ans galat ayega but arr[end] se hamesha shi ayega ....

  • @motivation_with_harsh
    @motivation_with_harsh Год назад +11

    //finding the target in sorted rotated array using binary search
    //ex-> A = {7,8,9,10,1}
    // key = 9
    //output -> element found at index 2
    //code written by harsh shukla
    #include
    using namespace std;
    int PivotInRotSortArr(int arr[] , int size){
    int s = 0 , e = size - 1;
    while(s arr[mid+1]){
    return mid+1;
    }
    else if(arr[s]

  • @ankitvarma1822
    @ankitvarma1822 2 года назад +1

    Bhaiya aap kamaal ho mazaa hi ajata hai ye quality Maine abhi tak kisi course main nahin dekhi

  • @shivamjha6580
    @shivamjha6580 2 года назад +14

    Thank you so much bhaiya for bringing such a great, full fledged and premium content in free of cost for all of us ❤🙏🙏🙏.....
    We are putting our effort 👌 💪 🙂 👏 🙌

  • @VivekSingh-dw1do
    @VivekSingh-dw1do Год назад +1

    Search in rotated sorted array brute force solution:-
    int search(vector& arr, int n, int k)
    {
    for(int i =0; i

  • @dheerajmehra320
    @dheerajmehra320 2 года назад +3

    what did i learn from this lecture
    1.how to find pivot element in rotated and sorted array
    2. how to find an element in rotated and sorted array
    3. how to find the square root of an element
    4. how to find the precesion of the square root

  • @mayankvishnani6333
    @mayankvishnani6333 2 года назад

    bhaiya aap smjate hi aaisa ho ki ek baar m smjh aa jaata hai. doosri baar sunna hi nhi padta

  • @shubham_jha
    @shubham_jha 2 года назад +18

    This series is very helpful; thanks a lot ❤️

  • @anmol3
    @anmol3 Год назад +2

    Easier way to implement precision using brute force
    double squareroot(int element, int integerpart, int precision){
    double ans=integerpart;
    double factor=1;
    for (int i=1; i

    • @YugiPlayz
      @YugiPlayz Год назад +1

      Note - For precision part we can make a function and convert the precision int into floating point num.... like 3 gets converted to 0.001
      float num = 37;
      float ans = findSqrt(num);
      while (true) {
      if ((ans + 0.01) * (ans + 0.01) < num) {
      ans += 0.01;
      } else {
      break;
      }
      }
      cout

    • @YugiPlayz
      @YugiPlayz Год назад +1

      Nested for loops bro... 😐😐😐

  • @kumarianshu6191
    @kumarianshu6191 Год назад +3

    East or west, bhaiya is the best!

  • @JackSparrow-z8s
    @JackSparrow-z8s Год назад

    you are the best teacher for DSA babbar bhaiya ,
    thank to that friend who recommended your channel for DSA

  • @tusharsingh1915
    @tusharsingh1915 Год назад +5

    Leaving this comment so that after an year if someone liked this cmmnt i'll be appreciating myself for my hard work. nd surely at that time i'll work in a good MNC.
    love from ghaziabad bhaiya:)

    • @Codeycodee
      @Codeycodee 9 месяцев назад

      what's your update bro

    • @tusharsingh1915
      @tusharsingh1915 9 месяцев назад

      @@Codeycodee well right now I'm pursuing MCA from BHU and getting placed in my 3rd sem🫂

    • @tusharsingh1915
      @tusharsingh1915 9 месяцев назад

      @@Codeycodee what about you brother

    • @mayanvajani934
      @mayanvajani934 5 месяцев назад

      @@tusharsingh1915 update brother?
      got placed?

  • @saranshagrawal5566
    @saranshagrawal5566 2 года назад

    Socha nhi tha kabhi RUclips se itna acha content milega. Thanks bhaiya

  • @jogindrasingh6139
    @jogindrasingh6139 2 года назад +5

    t's my humble request please maintain this consistency till end. We all are with you bhaiya. Sab ek sath placed honge👍and thankyou

    • @arnobbaiga309
      @arnobbaiga309 Год назад

      can u tell me why comparision takes place in 15;40 _ as s=4 and end =4 while statement doesnt satisfy here

  • @thenikhildaiya.
    @thenikhildaiya. Год назад +1

    I am so happy that i solved the square root of n question by myself after understanding the first 2 questions. Thank you so much for this useful lecture

  • @arpit441
    @arpit441 9 месяцев назад +4

    UPDATE GUYZZZZZ...........................Also correct me if i am wrong............the solution for sorted and rotated array can't solved every testcase in the leetcode platform it can solve 133/195 cases.............where array is [ 1 ] ...........target = 1 , output goes -1 but answer expected is 0.......we have to come up with an solution for this edge case....

    • @codingwale8
      @codingwale8 3 месяца назад

      good

    • @rajdeepverma7944
      @rajdeepverma7944 Месяц назад

      good

    • @ahmadrasheed2598
      @ahmadrasheed2598 Месяц назад +1

      This solution pases all the test cases
      int lowerPivot(vector& arr, int size){
      int s = 0;
      int e = size -1;
      int mid = s + (e - s)/2;
      while(s < e){
      if(arr[mid] >= arr[0]){
      s = mid + 1;
      }
      else{
      e = mid;
      }
      mid = s + (e - s)/2;
      }
      return s;
      }
      int binarySearch(vector& arr, int s , int e, int key){
      int start = s;
      int end = e;
      int mid = start + (end - start)/2;
      while(start

  • @kushwahashivbhan8269
    @kushwahashivbhan8269 2 года назад +2

    My friend tell me about this daa lecture series and now I learning this series for placement this time my second year is about to completed and really thank you bhaiya ❤️❤️❤️❤️

  • @Shivanand-49
    @Shivanand-49 2 года назад +3

    लाजबाब जबरजस्त जिंदाबाद🙏🙏🙏

  • @Jaytinho21
    @Jaytinho21 Месяц назад +1

    Search sorted array mein ham log direct arr[0] se compare nhi kr skte??
    If k>arr[0] lies in first prt
    Else lies in 2nd part

  • @aishwaryasam2319
    @aishwaryasam2319 2 года назад +5

    AMAZING! I was feeling really low today and I really wanted to give up, but I finished it in the end! Super glad :) Thanks bhaiya!

  • @aryangautam7506
    @aryangautam7506 2 года назад

    This course is best course for improving the problem solving in DSA

  • @anshbhatia9823
    @anshbhatia9823 2 года назад +16

    Solution for Search in Sorted Array by splitting in two parts:
    Approach:
    1. Get Pivot
    2. If key == arr[pivot] it is the answer
    3. if(key>=arr[0]) it lies in first half therefore, s=0, e = pivot-1
    4. else, it lies in second half therefore s= mid, e = size-1
    5. Now perform BS based on the selected values of e and s.
    Complexity = O(logn)
    Code:
    int getPivot(vector& arr,int n){
    int s = 0;
    int e = n-1;
    int mid = s + (e-s)/2;
    while(s=arr[0]){
    s= mid+1;
    }else{
    e = mid;
    }
    mid = s+(e-s)/2;
    }
    return s;
    }
    int findPosition(vector& arr, int n, int k)
    {
    int pivot = getPivot(arr,n);
    if(arr[pivot]==k){
    return pivot;
    }
    int s,e;
    //splitting array based on pivot element
    if(k>=arr[0]){
    e = pivot-1;
    s = 0;
    }
    else{
    e = n-1;
    s = pivot;
    }
    int mid = s + (e-s)/2;
    while(sk){
    e = mid-1; //move left
    }else{
    s = mid+1;
    }
    mid = s+(e-s)/2;
    }
    return -1;
    }

    • @arnobbaiga309
      @arnobbaiga309 Год назад

      can u tell me why comparision takes place in 15;40 _ as s=4 and end =4 while statement doesnt satisfy here

    • @rahulgopalka2403
      @rahulgopalka2403 Год назад +1

      @@arnobbaiga309 sir ne ek step aur lga de galti sai
      actually it dont take olace

    • @harshverdhanswami5850
      @harshverdhanswami5850 Год назад

      @@rahulgopalka2403 right!!

  • @vishalvaishnav8846
    @vishalvaishnav8846 2 года назад

    world best free course of DSA thank you Bhai Costly content ko Free me dene ke liye❤❤

  • @krishnaprabeesh2415
    @krishnaprabeesh2415 2 года назад +89

    Sorry sir , but the question in last video (Find Pivot in an array) was actually a point where left sum = right sum , but in video you are explaining something else . Please clarify this sir .

    • @anuragsrivastava1995
      @anuragsrivastava1995 2 года назад +16

      bro, at that point he means smallest in array.
      And in leet code question 33, there is definition of pivot where leftSum = rightSum.
      Hope you understand , that it is only a word that is vary from concept to concept

    • @krishnaprabeesh2415
      @krishnaprabeesh2415 2 года назад +16

      @@anuragsrivastava1995 thank you for trying but you just made it worse for me 😂😂🙏🏽

    • @anuragsrivastava1995
      @anuragsrivastava1995 2 года назад +3

      @@krishnaprabeesh2415 😂😂

    • @vaibhavagrawal431
      @vaibhavagrawal431 2 года назад +21

      > The Pivot index** is the index where the sum of all the numbers **strictly** to the left of the index is equal to the sum of all the numbers **strictly** to the index's right.
      **Pivot element** is the only element in input array ( Which is already a rotated sorted array) which is smaller than it's previous element. A pivot element divided a sorted rotated array into two monotonically increasing array.
      >

    • @chillkro25
      @chillkro25 Год назад

      ​@@vaibhavagrawal431 take one example like 3 4 1 2
      Pivot element -1
      Sum of left of pivot element -7
      Sum of right of pivot element-2
      Which is not equal

  • @souravsanyal7154
    @souravsanyal7154 Год назад +1

    One hour and I am going to say that you are a great teacher

  • @tanmaynagpal1737
    @tanmaynagpal1737 2 года назад +4

    Quality of the content is great, please continue the work.
    Much appreciated!

    • @arnobbaiga309
      @arnobbaiga309 Год назад +1

      can u tell me why comparision takes place in 15;40 _ as s=4 and end =4 while statement doesnt satisfy here

    • @VIPULARORA-rh5uz
      @VIPULARORA-rh5uz Год назад

      @@arnobbaiga309 bro comparision jo h vo phele hua like jab loop khtm nhi hua h and then jab ekk iteration puri hui uske baad s = 4 , e = 4 hua then loop end hogya

  • @dhruvjoshi8020
    @dhruvjoshi8020 2 года назад

    bhaiya wo pivot wale question ka kuch or Matlab dia hua tha leet code pe...
    find pivot index:-
    it is a index where sum of all numbers strictly to the left side of the index is equal to the sum of all the no.s strictly to the index's right.Return the leftmost pivot index.

  • @amankarn3025
    @amankarn3025 2 года назад +6

    Thank u bhaiya for giving such a great content 🥰🥰

  • @PraveenKumar-lf8cr
    @PraveenKumar-lf8cr Год назад +1

    Not going to quit ...definitely i will complete this whole series properly babbar bhaiya

  • @hiddenthings4820
    @hiddenthings4820 2 года назад +4

    You are amazing bhai ❤❤. Just one Question can we find square root of float numbers too using binary search?

  • @karangalhotra2370
    @karangalhotra2370 2 года назад +2

    Bhai aap fire ho... aapne ye course na krwaya hota toh DSA will alaways be a scary thing for most of us. Keep growing brother🔥🔥

  • @s.hariharanreddy5439
    @s.hariharanreddy5439 2 года назад +6

    MINIMUM ELEMENT IN AN SORTED AND ROTATED ARRAY-
    int findMin(int arr[], int n){
    //complete the function here
    if(arr[0]

    • @arnobbaiga309
      @arnobbaiga309 Год назад

      can u tell me why comparision takes place in 15;40 _ as s=4 and end =4 while statement doesnt satisfy here

  • @_tan2112
    @_tan2112 2 года назад +1

    Just completed the video explanation with the graph of pivot was soo good.
    Akri thak data raha 🎉

  • @venkatrajach6898
    @venkatrajach6898 2 года назад +4

    Hat's off to the dedication, every concept is crystal clear, commenting for better reach!!!

    • @arnobbaiga309
      @arnobbaiga309 Год назад

      can u tell me why comparision takes place in 15;40 _ as s=4 and end =4 while statement doesnt satisfy here

  • @parassetia4964
    @parassetia4964 2 года назад +1

    thank you bhaiya..bhot mzza aa rha hai...I observed you are working late night till 5 in the morning😂😂.
    bhot hard...bhot hard....bs josh thanda na pdne dena

  • @himanshugoyal5239
    @himanshugoyal5239 2 года назад +3

    Excellent stuff and loving this DSA series

  • @nikhildhakad2206
    @nikhildhakad2206 Год назад

    Sir ek logic ye bhi laga sakte he na ki...
    Apan ne mountain element nikala tha to ager apan last mountain element ka return thoda change ker de to bhi answer aa sakta he na...
    Jaise ki...
    .......
    return array[start+1];
    .......
    Isse ye ho ki jo top point hoga uska next element mil jaega Jo ki pivot point hoga...

  • @ashutoshaman9783
    @ashutoshaman9783 2 года назад +3

    Sir the code for pivot element is not working for some edge cases such as if the sorted array is rotated by zero or rotated by n whr n being the no of elements in the array
    is that true or i m doing somewhere wrong.

  • @063himanshumishra4
    @063himanshumishra4 2 года назад +2

    Bhai really learning a lot from you... Really like your videoes. Now I feel like I am being helped by my elder brother. Thank you so much bhaiya... Just one thing more than 1 hr video ko miss kr rha hu... Thank you so much bhaiya for helping.

  • @nadeem2944
    @nadeem2944 2 года назад +6

    bhaiya when we google search and on Leetcode also ..it defines pivot of an array as an index where the sum of all the numbers strictly to the left of the index is equal to the sum of all the numbers strictly to the index's right. can i get some more clarity on pivot of an array .. I'm little confused.

    • @rbrt8
      @rbrt8 2 года назад

      broh, apka confusion solve hua if yes then mujhe v btayen plz

  • @surajgupta-bc8lq
    @surajgupta-bc8lq 2 года назад

    Bhaiyaaa ekdam mazaaa aa rha h DSA padh ke...
    Bare Bhaiya apko koti-koti naaman 😇🙏

  • @nagrajwellness9720
    @nagrajwellness9720 2 года назад +6

    Love you bro please be constant till the end keep sharing your knowledge May god bless you

    • @nagrajwellness9720
      @nagrajwellness9720 2 года назад +1

      Love bhai how to write the code if the question is twisted

  • @sam8111
    @sam8111 2 года назад +1

    maza aagay bhaayya ji . By watching you it keeps increasing my interest in dsa❤❤

  • @shaswatpandey2991
    @shaswatpandey2991 2 года назад +6

    @CodeHelp - by Babbar! Bhaiya, you haven't mentioned the solution of " Q-724>> Find the Pivot Element" yet in leetcode?
    please, plz make our concept clear regarding that problem.

    • @summitrawat1093
      @summitrawat1093 2 года назад

      bhai pivot element hota kya h , plzz explain !!!!

    • @vanshajrathi1910
      @vanshajrathi1910 2 года назад

      @@summitrawat1093 pivot = minimum element in rotated sorted array

  • @fahadraza7152
    @fahadraza7152 Год назад +2

    All are going good...The way you present the lecture is excellent. Thank you so much for this DSA course

  • @patelrajkumarnareshkumar8156
    @patelrajkumarnareshkumar8156 2 года назад +12

    Rotated Sorted array using the second approach.
    int search(int* arr, int n, int k) {
    // Write your code here.
    int s = 0 , e = n - 1 , mid;
    while( s k) e = mid -1;
    else if(k > arr[0] && arr[mid] < k) s = mid + 1;
    else if(k > arr[0] && arr[mid] > k) e = mid -1;
    else return mid;
    }
    return -1;
    }

    • @rahulpant2002
      @rahulpant2002 2 года назад

      Code sahi run nahi kar raha bhai!!...

    • @shaheen-e-iqbal744
      @shaheen-e-iqbal744 2 года назад

      bhai aapke code ki second and third condition wrong he.....

    • @arnobbaiga309
      @arnobbaiga309 Год назад

      can u tell me why comparision takes place in 15;40 _ as s=4 and end =4 while statement doesnt satisfy here

  • @mff2129
    @mff2129 2 года назад +1

    Over powered -------> Babbar Bhaiya

  • @rondotTs
    @rondotTs 2 года назад

    is se best binary search nhi padha !! Hats off bhaiya ! :) YO!

  • @rahulgopalka2403
    @rahulgopalka2403 Год назад +5

    What is the 2nd and 3rd approach for the Searching element in the sorted rotated array?
    He talks about it at 27:44 in the video.
    Can anyone please share their approaches?

    • @piyushmalaviya7851
      @piyushmalaviya7851 Год назад +1

      Approch 2:
      int start = 0, end = n - 1;
      int mid;
      while (start

  • @ANMOL_367
    @ANMOL_367 8 месяцев назад +3

    iss videos mein kuch samajh nhi aa rha hai sir

  • @gamedeviitian3645
    @gamedeviitian3645 Год назад +1

    Search an Element in a Sorted & Rotated array using Binary Search
    beat 100 percent without see and discuss answer , now feelling motivated

  • @yashsinha9204
    @yashsinha9204 2 года назад +14

    // search in a sorted rotated array
    #include
    using namespace std;
    int search(vector& nums, int target) {
    int s=0;
    int e=nums.size()-1;
    while(s=nums[0]){
    //left side
    if(target>=nums[s] && targetnums[mid] && target

  • @1hokage8
    @1hokage8 Год назад +2

    Approach for Pivot Index:
    int numsLeft = 0;
    int numsRight = accumulate(nums.begin(), nums.end(), 0);
    for(int i = 0; i < nums.size(); i++)
    {
    numsRight -= nums[i];
    if(numsRight == numsLeft)
    {
    return i;
    }
    numsLeft += nums[i];
    }
    return -1;

    • @aniketk2500
      @aniketk2500 Год назад

      but complexity will be O(n) right?

  • @baraniyas9854
    @baraniyas9854 2 года назад +3

    //Search in a Rotated and Sorted Array
    #include
    using namespace std;
    int search(int a[], int n, int key)
    {
    int beg=0, end=n-1, mid;
    while(beg=a[0])
    {
    if(keykey)
    end=mid-1;
    else
    beg=mid+1;
    }
    else if(a[mid]=a[0])
    end=mid-1;
    else if(a[mid]>key)
    end=mid-1;
    else
    beg=mid+1;
    }
    }
    return -1;
    }
    int main()
    {
    int a[]={7,9,10,1,2,3};
    int n=sizeof(a)/sizeof(a[0]);
    int key=2;
    cout

  • @mdwaqar7401
    @mdwaqar7401 Год назад +1

    Mast Samjhaya ha Bhaiyya Aapne. Maza aa gaya.
    On to the Next Video.
    14 Videos Completed. 135 more to go.

  • @RohitRana-tz2lr
    @RohitRana-tz2lr 2 года назад +2

    I am strongly following you bhaiya.... Thanks, bhaiya for your efforts. This is my consistent 14th lecture.

  • @DominiK037
    @DominiK037 Год назад +2

    Samajh toh aa raha hai but I think I need to practice these questions few times in a single week !!! Thank you

  • @atharvkumar2564
    @atharvkumar2564 2 года назад

    bhaiya isse bhadiya content mujhe kahi nhi mila.I really your appreciate your efforts.Keep it up Bhaiya ji

  • @Naturel_over
    @Naturel_over 2 года назад +2

    East to West Love Babbar Bhaiya is the best ❤️🙇

  • @sanskarkeshri6852
    @sanskarkeshri6852 2 года назад

    We can also add a case like if element is not rotated but sorted then we return it's first element (a leetcode test case) so we can add an if condition like if(arr[0]

    • @zaidkhan-rx4bb
      @zaidkhan-rx4bb Год назад

      Yess but we can find only pivot using this logic , Not a key value k

  • @mohammedfarhaan7712
    @mohammedfarhaan7712 2 года назад +1

    if only he's a professor in college, then that college would be happiest place on earth --(big fan bhai🖤🖤)

  • @pranav_1056
    @pranav_1056 2 года назад +1

    Commenting for reach bhaiya, mai abhi 10th mei but I am preparing for INOI, so cp mei c++ aata hai and aapka hi course dekhunga promise. Abhi mai sabmei commenting for reach krta rahunga
    Love you 3000 babbar bhai ❤️

  • @DaniyalZafar5959
    @DaniyalZafar5959 4 месяца назад

    love form Pakistan Bro,
    your videos is really helpful for me and my class fellow as I am a university student but your videos means alot to me and my other class fellows.
    Thank you soo much for this helpfull series

  • @venkateshpk7822
    @venkateshpk7822 Год назад +1

    Precision finding was absolutely awesome
    You really deserve more views and likes

  • @namanjain6153
    @namanjain6153 11 месяцев назад

    in question to find sqrt, we can use end as n/2, because after n/2 there is no number which can be a multiple of n

  • @ParvKanungo
    @ParvKanungo Год назад +2

    bhaiya pivot element toh vo hota h na jisske left side ke elements ak sum right side ke elements ke sum ke equal ho....but aapne toh pure array me minimum element ko hi pivot bataya h...toh pivot ki koi pele se defination nhi hoti ky?...aur ky pivot element question to question vary krte h?

  • @Suneo07-x1
    @Suneo07-x1 Год назад

    very smooth way of teaching . Concept has been settled in the mind like if it is present there from the beginning.

  • @keenwean6812
    @keenwean6812 Год назад

    Seach element in rotated sorted array has 3 approach
    1) discussed in lecture involving pivot
    2) comparison with arr[0] and directly binary search
    But I am confused with the 3rd approach of which bhaiya was giving hint
    Please clarify 😅

  • @garvgoel1743
    @garvgoel1743 Год назад +1

    One doubt in sqre rot question - Can we not find precision again with binary search.
    For example- if we want precision of 2, then s=0.01 and e= 0.99 and then we can calculate via binary search.

  • @saurabhrajput7492
    @saurabhrajput7492 2 года назад +1

    good love this video.....become millionare soon bro