Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.
주어진 배열에서 0이 아닌 나머지 요소의 순서를 유지하면서 0을 전부 뒤로 보내라.
Input: [0,1,0,3,12]
Output: [1,3,12,0,0]
class Solution {
public void moveZeroes(int[] nums) {
int i = 0;
int j = 1;
while(j<nums.length){
if(nums[i] != 0){
i++;
j++;
} else if(nums[i] == 0 && nums[j] !=0){
nums[i] = nums[j];
nums[j] = 0;
i++;
j++;
} else if(nums[i] == 0 && nums[j] ==0){
j++;
}
}
}
}