/*
* @Author: sumBorn
* @Date: 2022-02-21 19:30:18
* @LastEditTime: 2022-02-22 14:27:19
* @Description: https://leetcode-cn.com/leetbook/read/all-about-array/x9p1iv/
*/
/**
* @description: 双指针
* @param {*}
* @return {*}
*/
public class Solution
{
public int RemoveElement(int[] nums, int val)
{
int arrLength = nums.Length;
int left = 0;
for (var right = 0; right < arrLength; right++)
{
if (nums[right] != val)
{
nums[left] = nums[right];
left++;
}
}
return left;
}
}
移除元素
最新推荐文章于 2025-05-22 10:04:48 发布