Accepted C# Solution


  • 0
    L
    public class Solution {
        public int RemoveDuplicates(int[] A) {
            int len = A.Length;
            if (len < 2) return len;
            int offset = 0;
            int i = 0;
            while (i + offset < len)
            {
                A[i] = A[i + offset];
                if (i + offset + 1 < len)
                    if (A[i] == A[i + offset + 1])
                        offset++;
                    else
                        i++;
                else
                    break;
            }
            return len - offset;
        }
    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.