class Solution { public: int removeElement(vector<int>& nums, int val) { int len=nums.size(),j=0; for (int i=0;i<len;i++){ if (nums[i]!=val) { nums[j]=nums[i]; j++; }else continue; } return j; } };
class Solution { public: int removeElement(vector<int>& nums, int val) { int len=nums.size(),j=0; for (int i=0;i<len;i++){ if (nums[i]!=val) { nums[j]=nums[i]; j++; }else continue; } return j; } };
转载于:https://www.cnblogs.com/travelller/p/9643169.html