sir i covered all corner cases but my code is not passing all test cases .
Even I tries aabbbccaa case its also running fine please help!
my code:
#include
#include <math.h>
#include
#include
using namespace std;
bool compare(int a, int b)
{
return a > b;
}
int main()
{
string a, b;
int count[256] = {0};
getline(cin, a);
b = a;
sort(a.begin(), a.end());
int max = 0;
string maxstring;
for (int i = 0; i < a.length(); ++i)
{
count[a.at(i)]++;
}
char current;
current = b.at(0);
for (int i = 1; i < b.length(); i++)
{
if (b.at(i) == current)
{
continue;
}
else
{
int index = current;
if (count[index] != 0)
{
cout << current << count[index];
}
count[index] = 0;
current = b.at(i);
}
}
if (count[current] != 0)
{
cout << current << count[current];
}
return 0;
}