Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

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(); 
} 
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #finding #unique #characters #string
ADD COMMENT
Topic
Name
3+7 =