Your set-approach is very nice, but if the list of data is huge, it is rather slow because you'll have to loop through the data list and count every member.