Find duplicates in a list efficiently | TCS