Search
 
SCRIPT & CODE EXAMPLE
 

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(); 
} 
Comment

PREVIOUS NEXT
Code Example
Cpp :: prime number program in c c++ 
Cpp :: quick sort c++ 
Cpp :: access first value in a set c++ 
Cpp :: cpp random number in range 
Cpp :: convert a int to string c++ 
Cpp :: c++ split string by space into vector 
Cpp :: addition without arithmetic operators c++ 
Cpp :: macro c++ 
Cpp :: remove element from vector on condition c++ 
Cpp :: string to int arduino 
Cpp :: c++ vector iterator 
Cpp :: removing a character from a string in c++ 
Cpp :: c++ rule of five 
Cpp :: tic toc toe c++ 
Cpp :: kruskal in c++ 
Cpp :: min element c++ 
Cpp :: how to convert int to string c++ 
Cpp :: round double to n decimal places c++ 
Cpp :: random number in a range c++ 
Cpp :: http.begin() error 
Cpp :: tuple c++ 
Cpp :: c++ function as param 
Cpp :: read text from file c++ 
Cpp :: max heap in c++ 
Cpp :: segmented sieve cpp 
Cpp :: How to find the suarray with maximum sum using divide and conquer 
Cpp :: vector size for loop 
Cpp :: read and write file in c++ 
Cpp :: detect end of user input cpp 
Cpp :: c++ how to add something at the start of a vector 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =