0
Deja Vu Challenge
Hi i Need help With my Code. 4 out of 5 cases are Succesful, only the Last case fails… i dont get the mistake to be honest 🙈 #include <iostream> using namespace std; int main() { bool DejaVu = false; string random, buffer; cin>>random; for(int i = 0; i<=random.size(); i++) { if(buffer.find(random[i]) == string::npos) { buffer += random[i]; } else { cout<<"Deja Vu"; DejaVu = true; } } if(DejaVu == false) { cout<<"Unique"; } return 0; }
2 Antworten
+ 4
For a character in a string repeating more than 1 time it outputs that many "Deja Vu".So , breaking the for loop after first repeating character is found , should do the work.
+ 1
That was the error 🙄 Thank You so much 🎉🎉 I hadnt this possibility in mind at all 🙈