Move Zeros To The end of Array❗❗ | Hello world Programming Logic Easy | Hindi Explained

Sdílet
Vložit
  • čas přidán 27. 01. 2022
  • This is the video under the series of DATA STRUCTURE & ALGORITHM. Now we are going to solve Move Zeroes under Array sections
    Join My Telegram channel for more Updates: telegram.me/helloworldbyprince
    complete DSA preparation: github.com/Prince-1501/Comple...
    ----------------------------------------------------------------------------------------
    Move Zeroes: leetcode.com/problems/move-ze...
    code of Move Zeroes: github.com/Prince-1501/Hello_...
    ----------------------------------------------------------------------------------------
    *Follow me *
    LinkedIn► / iamprince
    Facebook► / helloworldofficials
    Instagram► / helloworldbyprince
    Twitter► / prince_king_
    Telegram► telegram.me/helloworldbyprince
    ----------------------------------------------------------------------------------------
    ►Our Playlists on:-
    ► Tree: • Tree Data Structure & ...
    ► Hashing: • Hashing Data Structure...
    ► Graph: • Graph Data Structure &...
    ► Matrix: • Matrix (Multidimension...
    ► STL: • Standard Template Libr...
    ► Leetcode: • LeetCode Solutions And...
    ►Competitive Programming: • Full course in Competi...
    ►C++ Full Course : • C++ full Course in HINDI
    ►Algorithms: • L-01 || Prefix Sum Arr...
    ►Data Structure: • Data Structures with C...
    ------------------------------------------------------------------------
    🌟 Please leave a LIKE ❤️ and SUBSCRIBE for more AMAZING content! 🌟
    ✨ Tags ✨
    Move Zeroes
    Array playlist Hello world
    Depth First Search
    Array hello world
    Types of graphs in Data structure & algorithms
    Move Zeros To The end of Array
    playlist Graph Hindi
    hashing playlist Hello World
    question asked in Google
    off-campus placement
    how to learn to code for beginners
    Practice Tree data structure
    Flood Fill Algorithms
    The graph in a data structure in Hindi
    Graph Full playlist for Beginners
    algorithms
    graph
    dynamic programming
    data structure
    sorting algorithms
    algorithm analysis
    algorithm examples
    gate computer science preparation
    programming languages
    #Array #Leetcode #programming

Komentáře • 70

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

    Thanks for motivation. Initially I directly jumped into solution but you motivated to solve it and I did. My solution was not much optimized. Now watching video for proper clearance.

  • @user-zk1nw9nu7w
    @user-zk1nw9nu7w Před 5 měsíci

    hogya bhaiya yeh wala, took extra array for that, would love to learn new and more efficient approaches.

  • @shivasai2014
    @shivasai2014 Před rokem +1

    first, I thought let's check the solution instead of thinking about the solution but after listening to you, tried without lookin into solution and then boom got my solution🤯
    public void moveZeroes(int[] nums) {
    int j=0;
    for(int i=0; i

  • @shrodingerscat7099
    @shrodingerscat7099 Před rokem

    suppose if array is [1,0,0,3] here intially j is 0th position of array
    now keep on moving i until we reach non zero value ie - 3 now swap jth position with 3 and increase value of j here ur method fails ?

  • @iAm_Rohit_Raj
    @iAm_Rohit_Raj Před 2 lety +12

    Best approach according to me :-
    1) Count the number of 0s in the vector using *count(nums.begin(), nums.end(), target)* , here target = *0*
    2) Remove all the 0s, *nums.erase(remove(nums.begin(), nums.end(), target), nums.end())* , target = *0*
    3) Append all the 0s at the end using a for loop, *nums.push_back(0)*
    After submission it said, faster than 74.53% of C++ online submissions...
    Hope it helps !!! 😊😊😊

  • @oneminuteanimation-uz5yb
    @oneminuteanimation-uz5yb Před 11 měsíci

    bhaiya bona approach ka TC same hee hai na

  • @tarunbehera934
    @tarunbehera934 Před rokem

    why haven't you declared " int j " in 2nd for loop ??

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

    void moveZeroes(vector& nums) {
    int c=0;
    for(int i=0;i

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

    Yes 2nd approach kri maine but code nhi ho paya .. thank u ❤️

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

    I solved it before watching ur solution

  • @RitikKumar-bk6pj
    @RitikKumar-bk6pj Před 11 měsíci

    Bhaiya 2nd approach s kiya th code per wo fs gyi test cases mai

  • @Rafiullahsw007
    @Rafiullahsw007 Před rokem

    Where is the basics of these coding and what is the name of the app

  • @rahulkarmakar8067
    @rahulkarmakar8067 Před rokem

    class Solution:
    def moveZeroes(self, nums: List[int]) -> None:
    n=len(nums)
    l, h=0,0
    while(h

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

    In last approach there is no need to add zeros at last if we swap i and j in the loop

  • @nittinrana2277
    @nittinrana2277 Před 2 lety

    Thanks brother nice explanation

  • @PIYUSH-lz1zq
    @PIYUSH-lz1zq Před 2 lety +1

    bhaiaya , you can take cf medium level questions or DP or online assesment ke questions !!

  • @mehulsingh1216
    @mehulsingh1216 Před 2 lety

    Can anyone please tell the time complexity of 3rd approach? In which we are taking two pointers and checking if arr[i] is not equal to zero, then inserting it into arr[j]

    • @Coder_DhruvArora
      @Coder_DhruvArora Před 2 lety

      O(n) only

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

      @@Coder_DhruvArorait’s O(2N) but yeah if you consider drop constant way then yes it’s O(N)

  • @akshaygoyal4118
    @akshaygoyal4118 Před 4 měsíci

    var moveZeroes = function(nums) {
    let j=0
    for(let i=0; i< nums.length; i++){
    if(nums[i] == 0){
    [nums[i], nums[j]] = [nums[j], nums[i]];
    j++;
    }
    }
    return nums
    }; complex approach in js

  • @ParaScary62
    @ParaScary62 Před rokem

    I was incrementing the j after the if statement. That's why no changes were being happen in the array. 😑😑

  • @anujsonimca9531
    @anujsonimca9531 Před rokem

    mne kiya tha 2nd approach se
    its like O(n^2)

  • @oneminuteanimation-uz5yb
    @oneminuteanimation-uz5yb Před 11 měsíci

    bhaiya swap wela approach and last wela same time complexity hai hee too hoo reha hai na

  • @insidiousop3487
    @insidiousop3487 Před 10 měsíci +1

    i also did from the same approach 😁

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

      nice yar
      Please, share this channel in your college, groups, or LinkedIn bcoz it's cost nothing to you 😀

  • @rajchandra6913
    @rajchandra6913 Před rokem

    This is the best solution

  • @RahulGupta-hn5cl
    @RahulGupta-hn5cl Před rokem

    I thought Second Approach and solved it.

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

    merese hua tha lekin n2 complexity se

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

    Sir jo questions companies me aate hai geeksforgeeks me questions karwa digieye

  • @comp_rohityadav145
    @comp_rohityadav145 Před rokem

    Ho gya solve but Space complexity is O(n)

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

    swapping method is faster in both time and space complexity.

  • @arunavakirtan7621
    @arunavakirtan7621 Před 7 měsíci

    Nice explanation but I think my solution is more efficient.
    def pushZerosAtEnd(arr):
    n = len(arr)
    zero_index = 0
    for i in range(n):
    if arr[i] == 0:
    if i > zero_index:
    continue
    else:
    zero_index = i
    else:
    if zero_index < i:
    arr[zero_index], arr[i] = arr[i], arr[zero_index]
    zero_index += 1
    return arr

  • @user-rv3sz7fz5l
    @user-rv3sz7fz5l Před 7 měsíci +1

    Hi, I am from Pakistan........I am new to this leetcode ,I have only theoretical knowledge I have never implement such type of question ...what I do??? I am seeing your videos from the last three days .... I understand the question but can't think about approaches and more sad part is that also can't Implement code ....kindly suggest me how to be good at it ... Because I want to be good in it in 3 months......

    • @HelloWorldbyprince
      @HelloWorldbyprince  Před 7 měsíci +1

      Okay trust me and just start from my Playlist one by one
      1. Hashing
      2. Linked List
      3. Stack and Queue
      4. Heap
      5. Tree
      6. Graph
      Do whatever I said in the video and follow every instruction strictly.
      Each of my videos is based on one Question just try and learn from my videos and after completion of each Data structure just ping me over LinkedIn or CZcams comment section
      and jo v videos dekhte ho, put comments on that video so that I can also track your progress

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

      @@HelloWorldbyprince sure...!... Can I ask how you learned because you have such a clear concepts and approaches?

  • @nadeemmehraj5873
    @nadeemmehraj5873 Před rokem

    Bhaiya 5 bar attempted kiya or her baar naya constraint lagana pada phir bhi nahi hua

  • @anoopshetty3580
    @anoopshetty3580 Před rokem +1

    let temp = 0;
    for(let i=0; i

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

    second approch hum soche the

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

    ho gaya

  • @TheDailyProphet789
    @TheDailyProphet789 Před rokem

    first approah ki code hai kisi ke pass

  • @harshvardhanpande8409
    @harshvardhanpande8409 Před 2 lety

    I though 2nd approch

  • @gauravparasar4571
    @gauravparasar4571 Před rokem

    5:27 solve ke naam pr mene decreasing order me sort krne ka socha 😢😢😢😢

  • @vritra1537
    @vritra1537 Před 2 lety

    Nahi bana merse

  • @havefun8544
    @havefun8544 Před rokem +1

    Sort kardo and reverse it

  • @anjanishrivastava1273
    @anjanishrivastava1273 Před 5 měsíci

    KHUDA KA KASTA KYON BOLA JAI SHRI RAM BOLO KATALU