You should put the list of strings in std :: set . This is a data structure optimized for search. Searching if this element is in the set or not is an operation that is much faster than iterating through all the records.
When you are already using C ++ 11, you can also use std :: unordered_set , which is even faster to search because it is implemented as a hash table.
If it should be for a school / university: Be prepared to explain how these data structures handle faster. When your instructor asks you to explain why you used them, "some guys on the Internet told me" is unlikely to deserve a sticker in the textbook.
source share