Move all zeroes to end of array

PHOTO EMBED

Thu Dec 14 2023 06:23:05 GMT+0000 (Coordinated Universal Time)

Saved by @nistha_jnn #c++

class Solution {
public:
    void moveZeroes(vector<int>& arr) 
    {
        int n=arr.size();
       int pos=0;
       for(int i=0 ; i<n ; i++)
       {
           if(arr[i]!=0)
           {
               swap(arr[i],arr[pos]);
               pos++;
           }
       }    
    }
};
content_copyCOPY