Advertisement
Guest User

Untitled

a guest
Apr 4th, 2020
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.38 KB | None | 0 0
  1. class Solution {
  2.  
  3.     function moveZeroes(&$nums) {
  4.         $j = 0;
  5.         for($i = 0; $i < count($nums);) {
  6.             if ($j < count($nums)) {
  7.                 $nums[$i] = $nums[$j];
  8.                 if ($nums[$i] != 0)
  9.                     $i++;
  10.                 $j++;
  11.             } else {
  12.                 $nums[$i] = 0;
  13.                 $i++;
  14.             }
  15.         }
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement