27. Remove Element 發表於 2023-02-13 | 分類於 leetcode problemsolution1234567891011class Solution {public: int removeElement(vector<int>& nums, int val) { int slow = 0, fast = 0, n = nums.size(); while(fast<n){ if(nums[fast] !=val ) nums[slow++] = nums[fast]; fast++; } return slow; }}; analysis time complexity O(n) space complexity O(1)