+ 8

What's the wrong in this code?

#include <iostream> #include <string> std::string dejaVu(std::string); std::string dejaVu(std::string saisie) { std::string result; for (size_t i = 0; i < saisie.size(); i++) { if (saisie.find_first_of(saisie[i]) != i) { result = "Deja Vu"; break; } else { result = "Unique"; } } return result; } int main() { std::string str = "sammich"; std::cout << dejaVu(str); return 0; }

9th Jun 2020, 1:17 AM
Coder Kay
Coder Kay - avatar
5 Respuestas
+ 3
How? it show 2 test wrong.
9th Jun 2020, 1:57 AM
Coder Kay
Coder Kay - avatar
+ 1
It works in PC. I think there is no problem on it.
9th Jun 2020, 1:26 AM
James Clark I. Vinarao
James Clark I. Vinarao - avatar
+ 1
Did you consider case with empty input?
9th Jun 2020, 9:45 AM
Vera
Vera - avatar