Untitled

mail@pastecode.io avatar
unknown
plain_text
3 years ago
389 B
2
Indexable
Never
int remove_duplicate(int arr[], int n){
        if (n == 0 || n == 1)
            return n;
        int temp[n];
        int j = 0;
        int i;
        for (i = 0; i< n - 1; i++){
            if (arr[i] != arr[i + 1])
            temp[j++] = arr[i];
            temp[j++] = arr[n - 1];
        }
        for (i = 0; i< j; i++)
        arr[i] = temp[i];
        return j;
}