class Solution {
public int removeElement(int[] nums, int val) {
int fast = 0;
int slow = 0;
int len = nums.length;
while(fast<len){
if(nums[fast]!=val){
nums[slow] = nums[fast];
slow++;
}
fast++;
}
return slow;
}
}
快慢指针解决数组问题
最新推荐文章于 2024-08-22 17:27:46 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)