forked from altruistcoder/Data-Structures-Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
961f44b
commit a84bbcc
Showing
1 changed file
with
18 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
def removeDuplicates(a, n): | ||
if n == 0 or n == 1: | ||
return n | ||
j = 0 | ||
for i in range(0, n - 1): | ||
if a[i] != a[i + 1]: | ||
a[j] = a[i] | ||
j += 1 | ||
a[j] = a[n - 1] | ||
j += 1 | ||
return j | ||
|
||
|
||
a = list(map(int, input("Enter a list of elements: ").split())) | ||
n = len(a) | ||
m = removeDuplicates(a, n) | ||
print("The resultant array is:") | ||
[print(a[i], end=" ") for i in range(m)] |