Remove Duplicates from Sorted Array (With Algorithm & Python Code)

preview_player
Показать описание
Remove Duplicates from Sorted Array (With Algorithm & Python Code)

-~-~~-~~~-~~-~-
Please watch: "LRU Cache (With Python Code) "
-~-~~-~~~-~~-~-
Рекомендации по теме
Комментарии
Автор

Mam what will be the output for 1-2, 2-3, 3-4, 4-5, 5-6 test case

AnilKumar-wflb
Автор

by creating a temporary array, arent we breaking the in-place condition?

barulli
Автор

We have to remove duplicates no so what if we first convert into set and then append to empty list. Then also its working.

missionkillgaming
Автор

but range function goes up to but doesn't include the second value. For example: range(0, 5) = 0, 1, 2, 3, 4

tinasurlan
Автор

How it is removing duplicate...no. 3 does not have duplicate then too it is removing

prashantjena
Автор

arr = [1, 2, 3, 3, 4, 5, 5, 6, 6]

# Remove duplicates
arr_without_duplicates = list(set(arr))

print(arr_without_duplicates)

badsah
Автор

def dropdup(ls1):
count=0
dct={}
for i in range(len(ls1)):
if ls1[i] not in dct.values():
print(dct)
dct[count]=ls1[i]
count+=1
return list(dct.values())

piyushsharma
Автор

def remove_duplicates(a):
lista= []
for x in a:
if x not in lista:
lista.append(x)
else:
continue

return lista


if __name__ == "__main__":
a=[1, 1, 2, 2, 2, 3, 4, 4, 4, 5, 5]
print(remove_duplicates(a))

markkojo
Автор

Mam Hw do we do for unsorted array, a video on Tat pls

pygal
Автор

can't we use
return list(set(arr))

AbdulRehman-eezc
Автор

why don't you run the for loop and write the condition
new = []
for i in arr:
if i not in new:
new.append(i)

sumitwagh
Автор

one liner: list(set(number_list)), where number list is the list of numbers!

meetvardoriya
Автор

ahh we can just convert list into set and it automatically gets the unique entries

AbdulHaseeb-oteb
Автор

It is not a correct solution for every case.

puranjaigupta
welcome to shbcf.ru