```
public int removeElement(int[] nums, int val) {
int find = 0;
for (int i = 0; i + find < nums.length; i++) {
if (nums[i] == val ) {
nums[i] = nums[nums.length-1-find];
i--;
find++;
}
}
return nums.length - find;
}
```