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