Search in Rotated Sorted Array (LeetCode 33) | FREE DSA Course in JAVA | Lecture 55

Sdílet
Vložit
  • čas přidán 23. 01. 2023
  • This question has been asked in dream companies like Google, and Amazon and is a Leetcode problem number 33.
    The question reads - There is an integer array nums sorted in ascending order (with distinct values).
    Before being passed to your function, nums may be rotated at an unknown pivot index k. For example, (0,1,2,4,5,6,7) might be turned at pivot index 3 and become (4,5,6,7,0,1,2). You have to find the index of a given target value. if the target value is not present return -1.
    You must write an algorithm with O(log n) runtime complexity.
    Now if a search has to be done on an array in log n complexity, the only way you can do it, is by making a Binary search.
    But the trick is that it is not entirely sorted after the rotation and hence we need to follow a different approach.
    Let's see how we can solve this search in the rotated array problem in java.
    Subscribe to our channel for regular updates on the dsa course and click on the bell icon to never miss an update from our dsa course.
    Data Structures and Algorithms Free Course (Learn DSA Without Paise) Playlist - • Data Structures And Al...
    For more information, fill this form: forms.gle/8eiUmM92Fx563Aen9
    or call us at 8884881203
    Facebook: / thetapacademy
    Instagram: / tapacademy_online
    Linkedin: / 73820805
    Website: www.thetapacademy.com​

Komentáře • 23

  • @korenagaraju9668
    @korenagaraju9668 Před rokem +1

    one of the greatest explanation ever.❤❤

  • @mohammedkaif4104
    @mohammedkaif4104 Před 9 měsíci

    Sir you are the best teacher I have ever seen on the CZcams. Your explanation is the best Sir . 🫡

  • @rappalaraju7801
    @rappalaraju7801 Před 8 měsíci

    Superb explanation.

  • @ifhamhashir3595
    @ifhamhashir3595 Před rokem

    Thank you so much Really Great Explanation ❤

  • @mahaksoni7015
    @mahaksoni7015 Před rokem

    Legit explanation

  • @salonimaniyar3943
    @salonimaniyar3943 Před měsícem

    Best explanation

  • @snehakumari-nu4un
    @snehakumari-nu4un Před měsícem

    tnq sir for this wonderful explanation

  • @amansahu1178
    @amansahu1178 Před 3 měsíci

    Thanks 🙏

  • @mohammedparwezalam5383
    @mohammedparwezalam5383 Před rokem +1

    mind blowing explaination way

    • @TAPACADEMY
      @TAPACADEMY  Před rokem +1

      Thanks. Do subscribe and share our content so that it can reach to every student in need of quality content.

  • @dil08087
    @dil08087 Před 17 dny

    i didnt understand how is that right subarray sorted? @ 05:05

  • @anirudhr4710
    @anirudhr4710 Před 8 měsíci

    this is really great god pls make this yt channel reach to every cs students

  • @babubtech1844
    @babubtech1844 Před 3 měsíci

    class sorting{
    public static void main(String[] arg){
    int [] numbers ={9,8,6,6,4,3,3,22,11,23};

    Arrays.sort(numbers);
    System.out.println("Sorted Array");
    for(int number : numbers){
    System.out.print(number +" ");
    }
    it is the easy pattern try it once

  • @GunvantaDeshmukh
    @GunvantaDeshmukh Před 2 měsíci

    int arry[] = {7,8,1,2,3,4,5,6};
    int target = 7;
    This program fails when array[low] = target . Need to add one more condition to check this

  • @srin42
    @srin42 Před rokem

    Hello There, I was trying to contact course but I dont see any reply from you. I like your videos . Please do more.Also ,can you do a course for programming targeting goggle, meta, msft amazon. Please reply

    • @TAPACADEMY
      @TAPACADEMY  Před rokem +1

      Hi please contact +91 88923 91929

  • @sohamsonwane1534
    @sohamsonwane1534 Před 6 měsíci

    even the given example ans is not loved by this approch and i chek that my code and you code maches

  • @PreetiKumari441
    @PreetiKumari441 Před 6 měsíci

    class Solution {
    public int search(int[] nums, int target) {
    for(int i=0; i

    • @tanishadhakad.17
      @tanishadhakad.17 Před 5 měsíci +1

      this approach is based on linear search,for sorted arrays binary search is optimized approach.

  • @shitalshinde9387
    @shitalshinde9387 Před rokem +1

    Sir what about full stack development course?
    When will this course demo lectures has been started?
    Please tell sir please 🙏

  • @sohamsonwane1534
    @sohamsonwane1534 Před 6 měsíci

    sir but what if they have given a array as [2,4,5,6,7,0,1] to said to find 0 then how will we find

  • @Harshitraj27272
    @Harshitraj27272 Před 5 dny

    3,1 fail ho rha h isse