Facebook Interview Question: Write a python program to rem... | Glassdoor.co.uk

Interview Question

Data Engineering Manager Interview London, England

Write a python program to remove duplicates , keep the

  first occurrance

Interview Answer

2 Answers


def remove_duplicates(input_list):
        unique_list = []
        count_num = set([])
       for num in input_list:
              if not count_num or i not in count_num:
       return unique_list

Interview Candidate on 20 Jul 2018

Approach 1:
simply use set() function because set() can't have duplicates

list (set())

approach 2: Use inbuilt dictionary

list(dict.fromkeys ())

ANdy on 16 Dec 2018

Add Answers or Comments

To comment on this, Sign In or Sign Up.