Answers for "set() to remove duplicates in python"

2

remove duplicates function python

def remove_dupiclates(list_):
	new_list = []
	for a in list_:
    	if a not in new_list:
        	new_list.append(a)
	return new_list
Posted by: Guest on September-22-2020
0

remove duplicates in sorted array python

j = 0

// traverse elements of arr
for i=0 to n-2
    // if ith element is not equal to (i+1)th element of arr, then store ith value in arr[j]
    if arr[i] != arr[i+1]
        arr[j] = arr[i]
        j += 1

// store last value of arr in temp
arr[j] = arr[n-1]
j += 1

// print first j elements of array arr
for i=0 to j-1 
    print arr[i]
Posted by: Guest on December-11-2020

Code answers related to "set() to remove duplicates in python"

Python Answers by Framework

Browse Popular Code Answers by Language