#include <iostream>
#include <string>
#include <map>
using namespace std;
typedef long long int ll;
int main()
{
string s;
cin >> s;
map<char, int,greater <int>> m;
m['A'] = 1;
m['C'] = 1;
m['G'] = 1;
m['T'] = 1;
for(ll i = 0; i < s.length()-1; i++)
{
if(s[i] == s[i+1]) //ATTCGGGA
m[s[i]]++;
}
for(auto it = m.begin(); it != m.end(); it++)
{
cout <<it->first <<" " <<it->second<<endl;
}
//cout <<it->second<<endl;
return 0;
}
my desired output should be G 3 T 2 A 1 C 1 but its showing T 2 G 3 C 1 A 1 I dont know why this is happening as i have already mentioned it to be greater in the orderedmap. Please kindly solve the issue?
you could just simply use a queue. If you want to do it with a map use a multi_map(); and use the int as the key and the char as the value that way u will sort them according to the int value