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++; } } } };
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter