Dejavuu | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

Dejavuu

Anyone with the idea of how to solve the Dejavuu problem? Kindly assist

24th Sep 2021, 4:19 PM
Michael Owen
Michael Owen - avatar
10 Answers
+ 2
rupali Your code checks the characters are serial, here one of your code lines if(a[i] == a[i+1]) // this line checks just two characters in order. I mean, if you enter this string "gkhgkh" it says "Unique" but it must be "Deja Vu". If I'm wrong, said sth incorrect, I'm really sorry. But I told the reason.
24th Sep 2021, 6:13 PM
mesarthim
mesarthim - avatar
+ 1
Michael Owen Kindly share your attempt, so we can help you :)
24th Sep 2021, 4:24 PM
Rupali Haldiya
Rupali Haldiya - avatar
+ 1
#include <iostream> #include <string.h> using namespace std; int main() { char a[20]; cin>>a; int k; if (k=strlen(a)){ if(a[k]==a[k]){ cout<<"Deja Vu"<<endl; } else{ cout<<"Unique"; } } return 0; }
24th Sep 2021, 4:29 PM
Michael Owen
Michael Owen - avatar
24th Sep 2021, 4:44 PM
Rupali Haldiya
Rupali Haldiya - avatar
+ 1
Thank you
24th Sep 2021, 4:51 PM
Michael Owen
Michael Owen - avatar
+ 1
rupali Your code always prints "Unique". Cause if the characters in the given string are serial. Check your code. Happy coding!
24th Sep 2021, 5:43 PM
mesarthim
mesarthim - avatar
+ 1
rupali Okay, I see. Thanks for understanding. Happy coding!
24th Sep 2021, 8:25 PM
mesarthim
mesarthim - avatar
0
Michael Owen Your code always prints "Deja Vu". Cause you compare the same element with itself. Check your code. Happy coding!
24th Sep 2021, 5:41 PM
mesarthim
mesarthim - avatar
0
mesarthim it's running fine...And passing all the test cases...Will you please describe the issue a little bit more? :|
24th Sep 2021, 5:54 PM
Rupali Haldiya
Rupali Haldiya - avatar
0
mesarthim It's all right, to get correct answer according to your input we can use nesting of loops, but there is no need of nesting as the challenge says.
24th Sep 2021, 7:34 PM
Rupali Haldiya
Rupali Haldiya - avatar