You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class Solution {
public int removeDuplicates(int[] nums) {
if (nums.length == 0) return 0;
int k = 0;
for (int i = 1; i < nums.length; i++) {
if (nums[i] != nums[k]) {
k++;
nums[k] = nums[i];
}
}
return k + 1; // The length of the unique elements
}
}
The text was updated successfully, but these errors were encountered:
class Solution {
public int removeDuplicates(int[] nums) {
if (nums.length == 0) return 0;
}
The text was updated successfully, but these errors were encountered: