I C++11 I can do following:
multiset<int> ms {1,2,4,6,3,2,2,1}; // set will sort these elements automatically
std::pair<multiset<int>::iterator, multiset<int>::iterator> bounds;
// look for number 2 in the multiset
bounds = ms.equal_range(2);
for (auto v: ms)
{
cout << v << " ";
}
It gives 2 2 2 as there are three 2's in the multiset. How to do same in python?
I can do set only like this: ms = {1,2,4,6,3,2,2,1}. This set will sort the elements as well, but also removes duplicates. If I cant use set, is there other data structure for that?
Also what is equivalent of this ms.equal_range(2);
to search for multiple elements in python, like in c++.