Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,971 questions

51,913 answers

573 users

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 70 views
70 views asked Apr 7, 2025 by avibootz
1 answer 69 views
1 answer 91 views
91 views asked Jul 24, 2024 by avibootz
1 answer 100 views
100 views asked Jul 20, 2024 by avibootz
1 answer 103 views
103 views asked Jul 20, 2024 by avibootz
1 answer 127 views
127 views asked May 14, 2024 by avibootz
1 answer 115 views
115 views asked Jan 6, 2023 by avibootz
...