Interview Question

Junior Developer (Python) Interview

-

AKUNA CAPITAL

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

AnswerAdd Tags

Interview Answers

3 Answers

1

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

W on

0

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

Anonymous on

0

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

Jerry on

Add Answers or Comments

To comment on this, Sign In or Sign Up.