c++ - How to find unique element count in string array? -
this question exact duplicate of:
- how unique strings array c++ 4 answers
for example, have list of towns. 20 of them in fact, in 20 town string array there 4 unique towns, randomly scattered in array , can repeat. how find unique town count?
use std::set
, e.g.
std::set<std::string> myset(list_of_towns.begin(), list_of_towns.end());
assuming town names in std::vector called list_of_towns
.
Comments
Post a Comment