class Solution {
public int removeElement(int[] nums, int val) {
int len = nums.length;
int p=0;
int q=0;
while(q<len){
if(nums[q]!=val){
nums[p] = nums[q];
p++;
}
q++;
}
return p;
}
}
[27](https://leetcode-cn.com/problems/remove-element/)
Java算法之移除元素
最新推荐文章于 2024-11-16 21:36:47 发布