Lecture21: Solving LeetCode/CodeStudio Questions [Arrays]

Sdílet
Vložit
  • čas přidán 27. 07. 2024
  • In this Video, we are going to solve questions on Array:
    - Rotate arrays
    - Check if rotated and sorted array
    - Add arrays
    There is a lot to learn, Keep in mind “ Mnn boot karega k chor yrr apne se nahi yoga ya maza nahi para, Just ask 1 question “ Why I started ? “
    Visit Relevel: relvl.co/2smk
    Discord Server Link: / discord
    Course Flow: whimsical.com/dsa-4-placement...
    Homework: Added in Video already
    Notes Link: drive.google.com/file/d/11ACm...
    Code Links: github.com/loveBabbar/CodeHel...
    Question Links:
    - Rotate arrays: leetcode.com/problems/rotate-...
    - Check if rotated and sorted array: leetcode.com/problems/check-i...
    - Add arrays: bit.ly/3DXfsDZ
    Do provide you feedback in the comments, we are going to make it best collectively.
    Telegram Group Link: Love Babbar CODE HELP
    telegram.me/lovebabbercodehelp
    Connect with me here:
    Instagram: / lovebabbar1
    Twitter: / lovebabbar3
    Intro Sequence: We have bought all the required Licenses of the Audio, Video & Animation used.
    Timestamps:
    00:00 - Introduction
    00:36 - Rotate Arrays [Question 1]
    03:18 - Promotion
    04:22 - Approach
    08:13 - Code
    15:19 - Check if Sorted & Rotated array [Question 2]
    17:59 - Code
    22:14 - Add 2 arrays [Question 3]
    25:44 - Code
    #DSABusted #LoveBabbar

Komentáře • 623

  • @CodeHelp
    @CodeHelp  Před 2 lety +49

    Do Visit Relevel: relvl.co/2smk

    • @ShouryaPant
      @ShouryaPant Před 2 lety +5

      Bhaiyaa notes ki link galt dal gyi

    • @vijayalaxmi6937
      @vijayalaxmi6937 Před 2 lety +1

      reach++

    • @CodeHelp
      @CodeHelp  Před 2 lety +7

      @@ShouryaPant corrected

    • @ShouryaPant
      @ShouryaPant Před 2 lety +6

      @@CodeHelp thanx Bhaiyya You are Doing An Amazing Job. 👏 This Course Is Fantastic And awesome. KEEP it Up The Good Work🙂🙂

    • @siddharth7261
      @siddharth7261 Před 2 lety +1

      @@CodeHelp Sir, I can create an interactive blog that will help students to get topic wise notes along with code for this DSA course.

  • @shreyanshthakur5405
    @shreyanshthakur5405 Před 2 lety +55

    "Programming pe kam focus karo, engineering pe zyada focus karo" (Before bursting out to code, first break the problem into subparts or conditons). Awesome lecture bhaiya

  • @deeppatel0586
    @deeppatel0586 Před 2 lety +189

    if you hate the subject, its because of the teacher.
    if you love the subject, its because of the teacher.
    tremendous thanks babbar sir.

  • @cr7motive720
    @cr7motive720 Před 2 lety +18

    Blessings of many students are with you
    Keep going bhaiya 🙏🙏(respect)

  • @saignaneswarsutrave1171
    @saignaneswarsutrave1171 Před 2 lety +56

    My approach for Rotate Array problem:
    1. Reverse the whole vector
    2. Reverse the first k elements of the vector
    3. Reverse the remaining elements of the vector
    code:
    void rotate(vector &nums, int k){
    k = k % nums.size();
    reverse(nums.begin(), nums.end());
    reverse(nums.begin(), nums.begin() + k);
    reverse(nums.begin() + k, nums.end());
    }
    Dry run:
    arr = {1, 2, 3, 4}
    k = 2
    step 1: {4, 3, 2, 1}
    step 2: Reverse first two elements -> {3, 4, 2, 1} (k = 2 -> reverse elements present at 0th and 1st index)
    step 3: Reverse the remaining elements -> {3, 4, 1 , 2}

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

      hey did you get somewhere or this was your organic thinking if it was what was your approach

    • @_PRANAYMATE
      @_PRANAYMATE Před 9 dny

      @@ashish7604 Nice bro

  • @nischalgupta8050
    @nischalgupta8050 Před 2 lety +24

    I found your playlist on dsa few days ago and I loved this playlist

  • @iconliving9076
    @iconliving9076 Před 2 lety +1

    Best way of teaching. Quick and quirky. Please keep on making such videos.

  • @RohitRana-tz2lr
    @RohitRana-tz2lr Před 2 lety +1

    Thanks, bhaiya, I am continuously watching your DSA series. I am loving it so much

  • @awais_ansarii
    @awais_ansarii Před rokem +6

    Thank you for this placement series Bhaiya
    We're learning and enjoying a lot.

  • @er.preetiyadav1688
    @er.preetiyadav1688 Před 2 lety +12

    "why I started...?"
    This line motivates me a lot...
    Thnks bhaiya..❣️❣️

  • @amandeshpande8981
    @amandeshpande8981 Před 2 lety +1

    This is way better than uploading a 4 hr video In a day and taking break for weeks

  • @sounaksaha1455
    @sounaksaha1455 Před 2 lety +4

    Present Bhaiyaji,
    Aap sirf video dalte rahiye .. humare taraf se full support aur mehenat hum darshaate rahenge...
    Aur ye course duniya ka best course hai.

  • @RohitKumar-oo8lo
    @RohitKumar-oo8lo Před 2 lety +1

    Going great, bhaiya!
    Keep it up! We are with you!

  • @yatharthahuja1635
    @yatharthahuja1635 Před 2 lety +10

    Question 3) Add 2 arrays can also be done in the following way.
    vector reverse(vectorv){
    int s = 0;
    int e = v.size()-1;
    while(s=0;i--){
    res1 = res1 + (a[i]*mul);
    mul=mul*10;// this was the changing step
    }
    mul=1;
    for(int i=m-1;i>=0;i--){
    res2 = res2 + (b[i]*mul);
    mul=mul*10;
    }
    int total = res1+res2;
    while(total > 0){
    int ele = total % 10;
    ans.push_back(ele);
    total = total / 10;
    }
    return reverse(ans);
    }

  • @kunalkamthe8039
    @kunalkamthe8039 Před rokem +3

    This placement series is awesome bhaiya and best ever series on dsa ever...

  • @03_abhishekchoubey42
    @03_abhishekchoubey42 Před 2 lety +1

    The way you explain is really appreciable 🤩

  • @vigneshv7632
    @vigneshv7632 Před 2 lety +3

    I sticked until last minute. I am liking it. Let's keep the josh high🔥

  • @aniket_k720
    @aniket_k720 Před 2 lety +2

    Love bhaiyaa 🌹❤️
    Watching your videos since i was in class 11th .....now i am in college and feel.glad that am following ur videos since then.....helpsss too much........🌹

  • @akashthoriya
    @akashthoriya Před 2 lety +1

    me Saturday-sunday pura din beth ke, video dekhta hu aur practice bhi karta hu,
    Thank you bhai💛🤗

  • @piyushborkar6803
    @piyushborkar6803 Před 2 lety +1

    Love bhaiya content bohot tagde level ka aa raha hai 🔥🔥😍 Aise hi banate raho

  • @shamimahammadrasel5016

    Hello Babbar bhaiya your videos are so helpful, Thanks for this type of guideline.

  • @jagmohanrai2714
    @jagmohanrai2714 Před rokem

    Explanation of sum of array is awesome bhaiya best explanation I did not see anywhere,explanation like yours thanx

  • @abhaysingh1665
    @abhaysingh1665 Před 2 lety +2

    This line "Hello jii this is love babbar" gives us a peace and motivation that i can do 🙏🙏🙏

  • @anamitramaiti17
    @anamitramaiti17 Před rokem

    Bhaiya,pehle DSA se daar lagta tha par jab se aapka course start kiya tab se maza aa raha hai.Thank you Bhaiya!!!

  • @avijeetpaul1378
    @avijeetpaul1378 Před rokem +2

    love your channel sir, hats of to you.
    i have a small add-on to the last question, as i tried to solve the last question before hand of watching the solution, so i came up with my solution as:
    I would first convert the arrays into an integer, and the sum the both converted integer to get the final answer and then mod the answer with 10 to get the remainders and push that remainder into a vector and later reverse it to get the final answer.
    Code:
    #include
    vector findArraySum(vector&a, int n, vector&b, int m) {
    int sum1=0, sum2=0;
    int sig=0;
    for(int i=n-1;i>=0;i--){
    sum1=sum1+(a[i]*pow(10,sig));
    sig++;
    }
    sig=0;
    for(int i=m-1;i>=0;i--){
    sum2=sum2+(b[i]*pow(10,sig));
    sig++;
    }
    int sum=sum1+sum2;
    vector arr;
    while(sum!=0){
    int temp=sum%10;
    arr.push_back(temp);
    sum/=10;
    }
    reverse(arr.begin(),arr.end());
    return arr;
    }
    And thank you so much for your incredible persistence sir.

  • @ritikchaudhary1232
    @ritikchaudhary1232 Před 2 lety +7

    Rotate ques : Time complexity -> O(n)
    space complexity -> O(n) , n is size of nums vector.
    Sorted and Rotated : Time Complexity-> O(n)
    space complexity -> O(1)
    Add array : Time complexity -> O(m+n)
    Space Complexity -> O(m) or O(n).
    if I am wrong anywhere please correct me.

    • @KushalChandar.
      @KushalChandar. Před 2 lety

      I think
      Time Complexity-> O(max(m, n)); //only one of 2 while loops will execute //i,e i >= 0 or j >= 0
      Space Complexity-> O(max(m, n));
      //carry while loop does can actually be made into a if statement, i think carry can only be 0 or 1,
      correct me if i am wrong

  • @sadaf_r
    @sadaf_r Před 2 lety

    Question bahot sahi le rahe ho bhaiya...ekdum kadak level k🔥maja aagya

  • @varun-qm3xj
    @varun-qm3xj Před 2 lety

    bhaiya aj 3no question khud se lagaye maza he aagya. confidence next level hai ab

  • @theoneyt999
    @theoneyt999 Před 2 lety

    gaining confidence day after day :) THANK YOU BHAIYA @
    CodeHelp - by Babbar

  • @goldiison9663
    @goldiison9663 Před rokem +1

    First
    By the review of your course in CZcams i don't visit your channel but now from this video i recommend my friend your channel.

  • @hyderali1520
    @hyderali1520 Před 2 lety

    bhaiya apka solutions ka approach ko 100 topoo ki salamii.maja araha hai dsa karna ma ab pahla stress ata tha rona ata tha.

  • @user-cf9ur9yq2j
    @user-cf9ur9yq2j Před rokem

    Ek he to dil hai , kitne bar jitoge babbar bhai

  • @harshitjoshi2842
    @harshitjoshi2842 Před 2 lety +20

    Homework | Time Complexities |
    1> TC = O(n)
    SC = O(n)
    2> TC = O(n)
    SC = O(1)
    3> TC = O(n+m)
    SC = O (n+m)
    Awesome Lecture !!

    • @amitprakhar4802
      @amitprakhar4802 Před rokem

      Why it is showing time limit exceeded the find sum question

    • @amitprakhar4802
      @amitprakhar4802 Před rokem

      In gfg ide

    • @OmPrakash-vk4ko
      @OmPrakash-vk4ko Před rokem

      ig both time and space should be ----> O(min(M,N) + {max(M,N)-min(M,N)} + 1)
      becz 1st loop will run till one of the array ends
      2nd will run till other part and carry could not be of more than one digit
      Am I thinking right🤔

  • @karanmehra3305
    @karanmehra3305 Před rokem

    in question 3 we can use stack for the (sum of two arrays) resultant array . we don't need to write the reverse function .
    because the stack works on LIFO principal.
    thank you love bhai

  • @apoorvasunkad6686
    @apoorvasunkad6686 Před 2 lety

    Was eagerly waiting ❤️
    Thank you bhaiya 🤩

  • @adityasen2588
    @adityasen2588 Před 2 lety +1

    Sir well explained course is helpfull !!
    Thank you

  • @srajittanwar636
    @srajittanwar636 Před 2 lety +1

    Present sir, forever greatful.❤️

  • @harshk8609
    @harshk8609 Před 2 lety +82

    Request: web dev ka course kb tk aayega because dsa itna achaa h to pta nhi dev fir Kitna khaas hoga

    • @harshk8609
      @harshk8609 Před 2 lety +4

      @@shubham5934 bro jitna jldi hoga utna shi rhega

    • @siddheshabnave2101
      @siddheshabnave2101 Před 2 lety

      Tu 4th year mai hai?

    • @sjcreations2490
      @sjcreations2490 Před 2 lety +10

      @@shubham5934 bhia web development itna important nahi jitna dsa he. Aur waise bhi web d samajh sakte ho apne ap se par dsa samajhne ke liye teacher. So let bhaiya teach dsa first

    • @priyamtiwari391
      @priyamtiwari391 Před 2 lety

      Ruko jara sabar karo

    • @rameshmalhotra9525
      @rameshmalhotra9525 Před 2 lety

      czcams.com/video/tAQIKe0UGH4/video.html

  • @shashinibhat8989
    @shashinibhat8989 Před 2 lety +2

    Top level consistency🔥🔥🔥

  • @usersb685
    @usersb685 Před rokem

    bhaiya apne ye kaisa logic soch liya mujhe ye dekh ke differentiation yaad aaa gya

  • @kunalhole6911
    @kunalhole6911 Před 2 lety +4

    Bhaiyaa Time Complexity bhii Code kii discuss karna video may.
    After coding discuss the complexity of solution so Practise hoti rahagiii dono kiii code kii bhii aur complexity ki bhii.

    • @CodeHelp
      @CodeHelp  Před 2 lety +1

      will make it as a practice from next video

  • @amitshukla2268
    @amitshukla2268 Před 2 lety +16

    bhaiya thnx a lot , attendance marked, bss bhaiya eise hi 17 March tak course khtm krrdo . 🤗🔥

  • @mriduljain6809
    @mriduljain6809 Před 2 lety

    Amazing content Bhaiyaa.
    Thank you very much.

  • @geekyprogrammer4831
    @geekyprogrammer4831 Před rokem

    I like your course more than MIT Data Structures and Algorithms!

  • @scoc55vora15
    @scoc55vora15 Před rokem

    Amazing Lecture and Good Choice of Questions

  • @amitshukla2268
    @amitshukla2268 Před 2 lety +49

    My approach for 3rd question :-
    vector findArraySum(vector&a, int n, vector&b, int m) {
    int x=a[0],y=b[0];
    for(int i=1;i

    • @anuragraut5101
      @anuragraut5101 Před 2 lety +1

      this was the first approach that came to my mind after seeing the question

    • @bishalchatterjee745
      @bishalchatterjee745 Před 2 lety +2

      I did a similar code but was facing issue with the carry part.. Thanks for the help buddy>>!!

    • @amitshukla2268
      @amitshukla2268 Před 2 lety +3

      @@bishalchatterjee745 welcome bro :)

    • @taranjotsingh2374
      @taranjotsingh2374 Před 2 lety

      Thanks for the solution. @Amit Shukla but what would be the time complexity of this solution?

    • @bishalchatterjee745
      @bishalchatterjee745 Před 2 lety +1

      @@taranjotsingh2374 O(n)

  • @arungujjar7328
    @arungujjar7328 Před 2 lety +1

    Bhaiya, i just saw a comment in telegram channel which u shared... ignore that type of people they themselves are chu****...u are doing a great job... thanks a lot bhai for this type of content for free❣️🙌

  • @pranavchoudhary6491
    @pranavchoudhary6491 Před 2 lety +1

    Commenting for reach
    Babbar bhai great job ! ❤️

  • @I_Anupam_Pandey
    @I_Anupam_Pandey Před 2 lety +2

    attendance lecture 21
    thank you bhaiya for this amazing video
    aur notes ma lagta ha apke raw video file upload ho gaye haan

  • @9852963775aaa
    @9852963775aaa Před 2 lety

    bhaiya teeno questions solve hogaye thankyou so much bhaiya>>>>>>

  • @apurbakumarmajumder9478

    Love from Delhi bhaiya. Best DSA series.

  • @santoshahirwar6702
    @santoshahirwar6702 Před rokem

    "check if array is sorted and rotated" Sir is question me loop i=1 se i

  • @theskyraturi
    @theskyraturi Před rokem +2

    In third question (Add Arrays), Shouldn't Space Complexity be O(max(n,m)) ?

  • @vivekrai2305
    @vivekrai2305 Před 2 lety

    Attendence marked....bhaiya
    Really this is the best course for DSA

  • @riyarai670
    @riyarai670 Před 2 lety +1

    Present Bhaiya...🙋🏻‍♀️
    But I started a bit late so I am currently on lecture 14...but I will cope up for sure....😇

  • @poojayadav695
    @poojayadav695 Před 2 lety

    Attendance ✅
    Roz videos daalte raho bhaiya ❣️

  • @sanskrutishahu517
    @sanskrutishahu517 Před 2 lety

    great course so far 🙌🙌

  • @kartikey1796
    @kartikey1796 Před rokem

    sir your way of teaching is amazing. ❤

  • @pratyush2331raj
    @pratyush2331raj Před 2 lety +4

    Time Complexities
    Q1- TC = O(n)
    SC = O(n)
    OR
    // For recursive approach
    TC = O(n)
    SC = O(1)
    Q2- TC = O(n)
    SC = O(1)
    Q3- TC = O(max(n, m))
    SC = O(max(n, m))

  • @bcs_Jaskaran
    @bcs_Jaskaran Před rokem +1

    Check sorted and rotated :
    {
    int n = given.size();
    vector temp(n);
    temp = given;
    sort(given.begin(), given.end());
    vector check(n);
    for (int k = 0; k < n; k++)
    {
    for (int i = 0; i < n; i++)
    {
    int pos = (i + k) % n;
    check[i] = given[pos];
    }
    if (check == temp)
    {
    return 1;
    }
    }
    return 0;
    }

  • @ankushladani496
    @ankushladani496 Před 2 lety +1

    Abhi aaya hu dekhne ke pehle hi bol diya done..👍👍

  • @Aatifkhan-pq6kv
    @Aatifkhan-pq6kv Před 2 lety

    Present bhaiyya.... Enjoying the content🔥✌️✌️❤️❤️ ...

  • @abhay.1926
    @abhay.1926 Před 2 lety

    Present 🔥
    Love bhaiya op ❤️

  • @Shivamkumar-xu6hu
    @Shivamkumar-xu6hu Před 2 lety +2

    #consistency op
    Both your and mine let's see who will break first 😂

  • @atulkumarpandey3342
    @atulkumarpandey3342 Před 2 lety

    samajh aa gya bhaiya achche se.Thanks bhaiya.

  • @satvikshukla596
    @satvikshukla596 Před 2 lety

    Was eagerly waiting 🎉

  • @MohanSingh-rj3td
    @MohanSingh-rj3td Před rokem

    thanks for the beauty of coding

  • @vkgg6124
    @vkgg6124 Před 11 měsíci

    wah bahiya maza aa gya nice explanation ❣

  • @crazy_stanle
    @crazy_stanle Před 2 lety

    Semester chalrahe hai
    Semester khatam hote hi Sare vedios dekhlungaa
    APP DAREHAATE RAHOO
    BABBAR BRO

  • @shivkumar-og4ow
    @shivkumar-og4ow Před 2 lety

    thank you bhaiya . vedio was completed

  • @anuradhajadon4827
    @anuradhajadon4827 Před 2 lety

    Present sir
    Josh is always high of your students

  • @jiyasharma9225
    @jiyasharma9225 Před 9 měsíci +1

    second ques using modulus
    class Solution {
    public:
    bool check(vector& nums) {
    int n=nums.size();
    int count = 0;
    for(int i=0;inums[(i+1)%n]){
    count++;
    }
    }

    return count

  • @Madsaam09
    @Madsaam09 Před 2 lety

    Bhaiya best video series for cp🥰🥰

  • @user-mf9tr7lk4i
    @user-mf9tr7lk4i Před 7 měsíci

    My Approach for the first question is -->
    void rotate(vector arr, int key)
    vector::iterator it = arr.begin() + key - 1;
    reverse(arr.begin(), arr.end());
    reverse(it+1, arr.end());
    it = arr.begin() + key;
    reverse(arr.begin(),it);

  • @jayeshkaushik2975
    @jayeshkaushik2975 Před 2 lety +3

    What can be the optimised solution for add arrays❓

  • @saketsrivastava1424
    @saketsrivastava1424 Před 2 lety +1

    Thank you for the course Bhaiya

  • @sahilanand30
    @sahilanand30 Před 2 lety +1

    Best explanation 🔥

  • @uditkhandelwal7714
    @uditkhandelwal7714 Před 10 měsíci

    what is &nums represent in vector&nums

  • @nainaryan
    @nainaryan Před rokem +4

    we have to use ans.pop_back(sum);
    in 3rd question to avoid reverse function

  • @rishabhtyagi7369
    @rishabhtyagi7369 Před 2 lety +5

    Another solution for finding if the array is rotated or sorted or both:
    #include
    using namespace std;
    void check(int arr[], int n){
    int count = 0;
    for(int i = 0; iarr[i+1]){
    count++;
    }
    }
    if(count==1 && arr[0]>arr[n-1]){
    cout

  • @aditya_jainn
    @aditya_jainn Před 2 lety

    1) time complexity- O(n)
    2) O(n);
    3) O(n+m);

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

    thanks so much bhaiya for your effort

  • @akshayjain1332
    @akshayjain1332 Před 2 lety +5

    (my approach to q3: using some old tricks taught by luv bhaiya ❤️)
    vector findArraySum(vector&a, int n, vector&b, int m) {
    int num1 = 0 ;
    int num2 = 0 ;
    int sum = 0;
    vector ans;
    for(int i = 0;i

    • @taranjotsingh2374
      @taranjotsingh2374 Před 2 lety +1

      Can you help in explaining the time complexity of this solution

    • @AkshayKumar-gm7mx
      @AkshayKumar-gm7mx Před rokem

      your solution is good enough. but don't repeat the step to calculate num1 and num2. Just define a function to do that for u.

  • @sachindubey5365
    @sachindubey5365 Před 2 lety +1

    Bhaiya my approach was like first convert both the arrays in integer (by int ans=0,. For (int i=0;i

  • @veerendrarajpoot8186
    @veerendrarajpoot8186 Před 2 lety

    Thank you Bhaiya, bahut mast hai

  • @_GauravArya
    @_GauravArya Před 2 lety

    Luv bhaiya kamaal kr dete ho app

  • @sumitshetty295
    @sumitshetty295 Před 2 lety +14

    Another solution for Array rotation : (Using Reversal Algorithm)
    void rotate(vector& nums, int k)
    {

    int pos = nums.size()-(k%nums.size());

    //reversing last k elements
    reverse(nums.begin()+pos,nums.end());

    //reversing remaining nums.size()-k elements
    reverse(nums.begin(),nums.begin()+pos);

    //reversing whole vector
    reverse(nums.begin(),nums.end());
    }
    Time Complexity : O(N)
    Space Complexity: O(1)

  • @nayansinghal5157
    @nayansinghal5157 Před 2 lety

    @babbar bhaiya for first question can we do it with space complexity O(1)

  • @shubhamkhade4062
    @shubhamkhade4062 Před 2 lety

    thanks a lot bhaiyya ...... shayad lagta hai iss bar mera DSA complete ho jayega .... target 17 march 2022

  • @FENDI2551
    @FENDI2551 Před 11 měsíci +2

    my apporach for q3
    eg
    first we take a[ ] = { 4,5,1} and b[ ] = { 3,4,5}
    we add a as 451 by (ans x 10) + digit ( i.e here 4) == 4
    now ( 4 x 10 ) + 5= 45
    (45 x 10) +1 = 451
    similarly we get 345
    now we add them to get 796
    now
    Get the last digit of the number
    Insert the digit at the beginning of the vector
    number /= 10; // Remove the last digit from the number
    to get c[ ] ={7,9,6}
    open for suggestions

  • @keshavgambhir9894
    @keshavgambhir9894 Před 2 lety

    Present Bhaiya. Commenting for a better reach

  • @shuvapaul7070
    @shuvapaul7070 Před 2 lety +34

    Time Complexities
    Q1- Time=O(n)
    Space=O(n)
    Q2- Time=O(n)
    Space=O(1)
    Q3- Time=O(n+m)
    Space=O(n+m)

    • @dexterpane2085
      @dexterpane2085 Před 11 měsíci +6

      q3-
      tc-> O(max(n,m))
      sc->O(max(n,m))
      is it correct?

  • @discoverComputerprogramming7

    bool check(vector &arr){
    int count =0;
    for(int i=1; iarr[i] % arr.size())
    count++;
    }
    return count

  • @Abhishekkumarsingh-sl5yz

    bhaiya agar answer array mei store karteh toh problem ho sakti thi as size is fixed and swap karthe samay zero in front may be sme hacks nikal gae if carry>0 then only full array print kare nahi size -1.

  • @parultaneja6212
    @parultaneja6212 Před 2 lety

    how to do k rotate in space complexity o(1) without using extra space ?

  • @rahulstudies1178
    @rahulstudies1178 Před 2 lety +2

    q1) time complexity- O(n)
    q2) O(n);
    q3) O(n+m);

  • @udaypratapsingh8923
    @udaypratapsingh8923 Před 2 lety +1

    babbar is back 🔥🔥🔥

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

    Reverse array algo to rotate the array is better than modulo algo as in-place solution is require and it has better space complexity O(1).

  • @patelrajkumarnareshkumar8156

    As usual marking present bhaiya

  • @prasadprashantb.4001
    @prasadprashantb.4001 Před 2 lety

    Bhaiyaa last ka code thoda nhi smja.. Parr phle do achhe the 🙌🤘🤘❤❤thanks bhiyaa👏👏🙌🤝nice session on leetcode..