My issue
why my code is not working ig the logic is correct and same as the other submitted by other solution can anyone please figure what the fault ?
My code
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
string s;
cin >> s;
int length = s.size(), count = 0;
map<char, int> freq;
for (int i = 0; i < s.size(); i++) {
freq[s[i]]++;
}
map<char, int>::iterator itr;
for (itr = freq.begin(); itr != freq.end(); itr++) {
string numberString = to_string(itr->second);
int digitCount = numberString.size();
count += digitCount + 1;
}
if (count < length) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
return 0;
}
Problem Link: CHEALG Problem - CodeChef