0
Pour énoncé du problème, s'il vous plaît voir this.problème concernant la mauvaise sortie avec une déclaration HackerRank sur anagrammes
(j'omis les bibliothèques.)
Mon code fonctionne bien (lorsque les tests juge en ligne le code), sauf pour ce cas:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
J'aimerais savoir pourquoi la sortie il attend d'être 104 WHE n intersection est zéro?
std::string string_intersection;
int number_needed(string a, string b) {
int y = a.length();
int z = b.length();
sort(a.begin(), a.end());
sort(b.begin(), b.end());
std::set_intersection(a.begin(), a.end(), b.begin(), b.end(), std::back_inserter(string_intersection));
int num, x = string_intersection.length();
if(x==0)
num = 0;
else
num = y + z - 2*x;
return num;
}
int main(){
string a;
cin >> a;
string b;
cin >> b;
cout << number_needed(a, b) << endl;
return 0;
}
La partie vitale que je manquais. Merci! – stoicGoyal