+ 1

Can anyone suggest me a way to print duplicate values in an array?

And also it should print the duplicate value and the count of that number

30th Dec 2020, 2:38 PM
Kalindu Wanasinghe
Kalindu Wanasinghe - avatar
3 Respostas
+ 5
Kalindu Wanasinghe , please show us your attempt first. If you have not done a try by yourself upto now, please do so. put your code in playground and link it here. Thanks
30th Dec 2020, 3:42 PM
Lothar
Lothar - avatar
+ 2
Using std::map is one possible way https://en.cppreference.com/w/cpp/container/map
30th Dec 2020, 3:43 PM
Ipang
+ 2
Use "count" from the <algorithm> hearer file, and if the count is more than 1, just output it. might be better to put the array into a set then do a simple "for in" loop but use "count" with the original array.
30th Dec 2020, 7:02 PM
rodwynnejones
rodwynnejones - avatar