题目描述:
解题思路:
/**
* @param {number[]} nums
* @return {number}
*/
var removeDuplicates = function (nums) {
var index = 0;
if (nums.length < 2) {
return nums.length;
}
for (key in nums) {
if (nums[key] != nums[Number(key) + 1]) {
nums[index] = nums[key];
index++;
}
}
return index;
};
运行结果: