Search in a Rotated Sorted Array (LeetCode 33) | Full solution with examples | Study Algorithms

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

Комментарии • 40

  • @dobermanbruce2397
    @dobermanbruce2397 Год назад +19

    When I need solution of any problem first I came and check if your video is present. You provide a greatExplanation. ThankYOu

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

      that is so delightful to hear :)

  • @krishnavishwakarma8637
    @krishnavishwakarma8637 10 месяцев назад +4

    Your explanation is really awesome bro. you are my goto person .. 👋

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

    Amazing man! Your videos are easy to understand!

  • @hanumantkhandagale7872
    @hanumantkhandagale7872 3 года назад +3

    Great explanation.... thank you sir 👍😀

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

    Thank you so much sir!

  • @saaikrahaanth
    @saaikrahaanth 11 месяцев назад +1

    bro such a sweet naration

  • @NafisaParveen-g9t
    @NafisaParveen-g9t 6 месяцев назад

    thanks a lot sir, this explanation really helped a lot!!😄

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

    awesome sir.. pls continue other problems too.

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

      I will keep them coming

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

    awesome video!

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

    Amazing

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

    What happens when both the parts are sorted the serach may be directed to wrong direction when if block condition is being satisfied

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

      can you please clarify your doubt?

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

    🥰🥰🥰ThankYOu

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

    extremely good explanation

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

    Thankyou sir.

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

    thank you sir

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

    Thanks

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

    My real question is
    the question asks us to find the index of the target value and the target value is aready given in the question.. Cant we just do a normal search for the target value and pass the index of the target value?

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

      same doubt.. :\

    • @CS__ARYANSRIVASTAVA
      @CS__ARYANSRIVASTAVA 10 месяцев назад +1

      The question asks us to achieve the time complexity of O(log n), whereas a normal linear search would give a time complexity of O(n) that is larger than required.

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

    On the 13th min, mid value will be 0+ (3-0)/2 = will be 1.

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

      a small error on my side...but glad you followed it all along 😄

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

    first of all sorry if you found this a silly 1, if the given arr is : [4,5,6,7,0,1,2] and target is 0; as per your code, in the main part of ELSE (arr[mid] from the given array going on the mid is 1 and target is 0, how is it even possible? as( 1

    • @nikoo28
      @nikoo28  Год назад +4

      // If right half is sorted
      if (arr[mid]

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

    brute force solution is different and question is different , am I one who is finding this difference ?🤔 is it just searching element in array ?

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

    why you are using test cases please direct write the psvm code main fully to understadn and can run in intellij ide

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

      You should always write test cases as a good coding practice. Also, the focus should be on writing methods and not the main function. That is why all programming platforms only ask you to implement methods.
      Given all this, if you still want to write the psvm method…just copy the test case in the main method and call using the object.
      The code will work as expected.

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

      @@nikoo28 i want to know how to run without test cases using psvm

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

      @@nikoo28 assertEquals(1, searchInRotatedSortedArray.search(nums, 4));
      assertEquals(1, searchInRotatedSortedArray.alternateSearch(nums, 4));
      what to put instead of assertEquals

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

      ​@@infinite639
      public static void main(String args[]) {
      // Code to input an array and target
      // inputArr
      // target input
      // Create object
      SearchInRotatedSortedArray someObject = new SearchInRotatedSortedArray();
      // Get the output
      int result = someObject.search(inputArr, target);
      // Print the result
      System.out.println(result);
      }

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

      @@nikoo28 i find this today thank you for your videos and for help ❤️

  • @unknown-mf7dd
    @unknown-mf7dd 2 месяца назад

    without recursion, simple solution
    public int search(int[] nums, int target) {
    int n = nums.length;
    int left = 0;
    int right = n-1;
    while(left

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

    I think bruteforce approach is enough for this problem, 2nd one also good

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

    Bro 3/2 = 2. You are saying on 13.00 min ...ha haa 😂😂. You r wrong

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

      You get the idea what we are doing here :)

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

      @@nikoo28 yes