Home
Recent Q&A
Java
Cloud
JavaScript
Python
SQL
PHP
HTML
C++
Data Science
DBMS
Devops
Hadoop
Machine Learning
Azure
Blockchain
Devops
Ask a Question
How to find duplicates in a vector ?
Home
C Plus Plus
How to find duplicates in a vector ?
+1
vote
asked
Jul 16, 2019
in
C Plus Plus
by
Indian
How to find duplicates in a vector ?
#c
#vector
#stl
Please
log in
or
register
to answer this question.
1
Answer
0
votes
answered
Jul 16, 2019
by
Indian
Create a map of <string , int> type to store the frequency count of each string in vector.
Iterate over all the elements in vector try to insert it in map as key with value as 1.
If string already exists in map then increment its value by 1.
Your comment on this answer:
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Related questions
+1
vote
Q: How to get element by index in vector | at() vs operator []
asked
Jul 16, 2019
in
C Plus Plus
by
Indian
#c
#vector
#stl
+1
vote
Q: How to compare two vectors | std::equal() & Comparators
asked
Jul 16, 2019
in
C Plus Plus
by
Indian
#c
#vector
#stl
+1
vote
Q: what is Friend class and function in C++?
asked
Jul 16, 2019
in
C Plus Plus
by
Indian
#c
#vector
#stl
+1
vote
Q: Major C++ features
asked
Jul 16, 2019
in
C Plus Plus
by
Indian
#c
#vector
#stl
+1
vote
Q: What are the differences between references and pointers?
asked
Jul 16, 2019
in
C Plus Plus
by
Indian
#c
#vector
#stl
+1
vote
Q: What is Polymorphism? How is it supported by C++?
asked
Jul 16, 2019
in
C Plus Plus
by
Indian
#c
#stl
#oops
+1
vote
Q: What is Abstraction?
asked
Jul 16, 2019
in
C Plus Plus
by
Indian
#c
#stl
#oops
+1
vote
Q: What is Inheritance? What is the purpose?
asked
Jul 16, 2019
in
C Plus Plus
by
Indian
#c
#stl
#oops
+1
vote
Q: What is encapsulation?
asked
Jul 16, 2019
in
C Plus Plus
by
Indian
#c
#stl
#oops
+1
vote
Q: What is Object Oriented Programming?
asked
Jul 16, 2019
in
C Plus Plus
by
Indian
#c
#stl
#oops
...