LeetCode 26. Remove Duplicates from Sorted Array Posted on 2021-04-06 Edited on 2024-11-24 In LeetCode 123456789101112class Solution {public: int removeDuplicates(vector<int>& nums) { int n = nums.size(); if (n == 0) return 0; int i = 0; for (int j = 1; j < n; ++j) if (nums[i] != nums[j]) nums[++i] = nums[j]; return i + 1; }};