题目链接

【题解】

沙比提

【代码】

class Solution {
public:
    int removeElement(vector<int>& nums, int val) {
        int cur = 0;
        int len = nums.size();
        for (int i = 0;i < len;i++){
            if (nums[i]!=val){
                nums[cur++] = nums[i];
            }
        }
        return cur;
    }
};

相关文章:

  • 2021-05-26
  • 2022-01-07
  • 2021-10-09
  • 2022-12-23
  • 2021-10-16
  • 2021-12-06
  • 2021-05-31
猜你喜欢
  • 2021-06-02
  • 2021-04-04
  • 2021-06-20
  • 2022-12-23
  • 2021-12-26
  • 2021-06-21
  • 2021-12-08
相关资源
相似解决方案