27. Remove Element
原题链接:https://leetcode.com/problems/remove-element/description/
这道题目是“Easy”级别的,实现起来也确实容易!
class Solution {
public int removeElement(int[] nums, int val) {
int len = nums.length;
for(int i = 0; i < len; i++) {
while (nums[i] == val && i < len) {
nums[i] = nums[--len];
}
}
return len;
}
}