标签:remove 需要 span rgs for 等于 修改 ati out
public class Test { public int removeElement(int[] nums, int val) { int i = 0; for (int j = 0; j < nums.length; j++) { if (nums[j] != val) { nums[i] = nums[j]; i++; } } return i; } public static void main(String[] args) { //int dis = 1; int[] nums = {0,1,2,2,3,0,4,2}; System.out.println(new Test().removeElement(nums, 2)); } }
标签:remove 需要 span rgs for 等于 修改 ati out
原文地址:https://www.cnblogs.com/pxy7896/p/12047362.html