AKUNA CAPITAL Interview Question

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

Interview Answers

Anonymous

Mar 14, 2018

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

2

Anonymous

Apr 13, 2022

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

Anonymous

Oct 12, 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