Find duplicates in a list efficiently | TCS Interview Question