Pergunta de entrevista da empresa AKUNA CAPITAL

How to remove duplicated items in a list? What's the complexity of your algorithm?

Respostas da entrevista

Sigiloso

14 de mar. de 2018

def rem_dupe(input_list): x = set(input_list) return [y for y in x]

2

Sigiloso

13 de abr. de 2022

def remove_duplicates(arr): return list(dict.fromkeys(arr).keys())

Sigiloso

12 de out. de 2017

def remove_duplicate(l): ...: res = [] ...: n = len(l) ...: if n < 2: ...: return l ...: for i in range(1,n): ...: if l[i-1] != l[i]: ...: res.append(l[i-1]) ...: res.append(l[-1]) ...: return res