first i need to remove the duplicate entries from the array program in python code example
Example 1: remove duplicates in sorted array python
j = 0
for i=0 to n-2
if arr[i] != arr[i+1]
arr[j] = arr[i]
j += 1
arr[j] = arr[n-1]
j += 1
for i=0 to j-1
print arr[i]
Example 2: Remove duplicates from a list (keep first occurrence)
list_rset([], []). % keep rightmost occurrences
list_rset([E|Es], Rs0) :-
if_(memberd_t(E, Es),
Rs0 = Rs,
Rs0 = [E|Rs]),
list_rset(Es, Rs).
list_lset([], []). % keep leftmost occurrences
list_lset([E|Es], Ls) :-
post_pre_lset(Es, [E], Ls). % uses internal auxilary predicate
post_pre_lset([], _, []).
post_pre_lset([E|Es], Pre, Ls0) :- % 2nd arg: look-behind accumulator
if_(memberd_t(E, Pre),
Ls0 = Ls,
Ls0 = [E|Ls]),
post_pre_lset(Es, [E|Pre], Ls).