Is there any way to find the all the unique characters present in a string without finding all the occurrences of the string ? For example, Let it be s
Make a set of characters and put all items from string to it, then you will have set with "alphabet" of your string.
E.g.:
#include
#include
#include
int main(void)
{
std::string a = "mississippi";
std::set alphabet;
alphabet.insert(a.begin(), a.end());
std::cout << "Set of chars has " << alphabet.size() << " items." << std::endl;
for (auto a : alphabet)
{
std::cout << a << std::endl;
}
}
Original string is not modified in that example and there is no need to pre-sort.