Skip to content

Commit d9f4148

Browse files
committed
Remove Duplicates from Sorted Array
1 parent d5d2ab7 commit d9f4148

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

remove_duplicates_sorted_array.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#include <iostream>
22
using namespace std;
33

4-
int removeDuplicates(int arr[], int n)
4+
int removeDuplicates(int a[], int n)
55
{
6-
if(n==0 || n==1)
6+
if(n==0||n==1)
77
return n;
8-
int j = 0;
8+
int j=0;
99
for(int i=0; i<n-1; i++)
10-
if(arr[i] != arr[i+1])
11-
arr[j++] = arr[i];
12-
arr[j++] = arr[n-1];
10+
if(a[i] != a[i+1])
11+
a[j++] = a[i];
12+
a[j++] = a[n-1];
1313
return j;
1414
}
1515

0 commit comments

Comments
 (0)