import java.util.Objects; class Solution { public int removeElement(int[] nums, int val) { if (Objects.isNull(nums) || nums.length == 0) { return 0; } int num = 0; for (int i = 0; i < nums.length; ++ i) { if (nums[i] != val) { nums[num ++] = nums[i]; } } return num; } }
LeetCode - 27. 移除元素
猜你喜欢
转载自blog.51cto.com/tianyiya/2172729
今日推荐
周排行