Answers for "to count the number of unique characters in a string c++"

C++
0

finding no of unique characters in a string c++

int countDistinct(string s) 
{ 

    unordered_map<char, int> m; 

    for (int i = 0; i < s.length(); i++) { 
        m[s[i]]++; 
    } 

    return m.size(); 
}
Posted by: Guest on July-15-2020

Code answers related to "to count the number of unique characters in a string c++"

Browse Popular Code Answers by Language