LeetCode 27. Remove Element
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; } };