What to include to use unordered_set in C++

1 Answer

0 votes
#include <iostream>
#include <unordered_set>

int count_unique_char(std::string str) {
    std::unordered_set<char> st;
 
    for (int i = 0; i < str.size(); i++) {
        st.insert(str[i]);
    }
 
    return st.size();
}
 
int main() {
    std::string str = "javascript typescript node.js c c++";
 
    std::cout << count_unique_char(str);
}
 
 
 
 
 
 
/*
run:
 
17
 
*/

 



answered May 4, 2022 by avibootz

Related questions

1 answer 87 views
1 answer 108 views
108 views asked Jul 24, 2024 by avibootz
1 answer 116 views
116 views asked Jul 20, 2024 by avibootz
...