time complexity of erasing repeated entries
The basic algorithm is to first put all the members of S into a hash table $\mathcal{S}$.  Then walk down the list T, recording its elements in a hash table $\mathcal{T}$ as you go.  If an element has already been recorded in hash table $\mathcal{T}$ then you delete it from T.  If an element does not appear in hash table $\mathcal{S}$ then you delete it from T.  When you've completed your walk down T, there will be no repeated elements left in it and every remaining element will be a member of S.  

Hash table insertions and lookups have amortized O(1) runtime so the whole algorithm scales O(n).