public class Solution { public int removeDuplicates(int[] A) { if(A.length == 0) return 0; int count = 1; for(int i = 1; i < A.length; i++){ if(A[i-1] == A[i]) continue; A[count++] = A[i]; } return count; } }
2023-12-21 13:14:21
public class Solution { public int removeDuplicates(int[] A) { if(A.length == 0) return 0; int count = 1; for(int i = 1; i < A.length; i++){ if(A[i-1] == A[i]) continue; A[count++] = A[i]; } return count; } }