import java.util.*;
public class Solution {
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param nums int整型ArrayList
* @return int整型
*/
public int removenums (ArrayList<Integer> nums) {
// write code here
int preNum = -1;
int account = 0;
for (int i = 0; i < nums.size(); i++) {
int currentNum = nums.get(i);
if (currentNum != preNum) {
preNum = currentNum;
account = 1;
}
else {
if (account + 1 == 3) {
nums.remove(i);
i--;
}
else {
account++;
}
}
}
return nums.size();
}
}