fork download
  1. #include <iostream>
  2. #include<vector>
  3.  
  4. using namespace std;
  5. class Solution {
  6. public:
  7. void moveZeroes(vector<int>& nums) {
  8. // create a vector which store all the elements rather than 0
  9. vector<int> v1;
  10. int count;
  11. // Run the loop for the given problems
  12. for(int i=0;i<nums.size();i++){
  13. if(nums[i]!=0){
  14. v1.push_back(nums[i]);
  15.  
  16. }
  17. else{
  18. count=count+1;
  19. }
  20.  
  21. }
  22.  
  23. // The left over elelments should be stored after the non zero elements
  24.  
  25. }
  26. };
  27.  
  28.  
  29.  
  30.  
  31. int main() {
  32. // your code goes here
  33. return 0;
  34. }
Success #stdin #stdout 0s 5304KB
stdin
Standard input is empty
stdout
Standard output is empty