Can anyone tell the 5th test case? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Can anyone tell the 5th test case?

What is the 5th test case of Deja Vu?

2nd Feb 2021, 3:18 PM
Gajendra Jangid
Gajendra Jangid - avatar
7 Answers
+ 1
import java.util.*; public class Program { public static void main(String[] args) { Scanner sc=new Scanner (System.in); String n=sc.nextLine(); n=n.toLowerCase(); int f=0; for(int i=0;i<=n.length()-2;i++){ char c=n.charAt(i); for(int j=i+1;j<=n.length()-1;j++){ char d=n.charAt(j); if(c==d) ++f; } } if(f>0){ System.out.println ("Deja Vu"); } else{ System.out.println ("Unique"); } } } See this is the simplest answer.
2nd Feb 2021, 5:18 PM
Atul [Inactive]
+ 3
No one knows it. Better would be to copy paste your code here or a link to it so others can see what else needs to be added to it
2nd Feb 2021, 3:19 PM
Abhay
Abhay - avatar
+ 2
You are making your code bit complex. See first take first position and then go upto the last of the word Example for(int i=0;I<a.length()-1;I++){ for(int j=I+1;j<a.length();j++){ Then check for the equality
2nd Feb 2021, 3:55 PM
Atul [Inactive]
+ 1
Just paste your code here
2nd Feb 2021, 3:24 PM
Atul [Inactive]
+ 1
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner s = new Scanner(System.in); String a = s.next(); String m = "false"; for(int i=1;i<=a.length() -1;i++){ for(int j=0;j<i;j++){ if(a.charAt(j)==a.charAt(i)){ System.out.print("Deja Vu"); m = m.replaceAll("false","true"); break; } } } if(m == "false"){ System.out.print("Unique"); } } }
2nd Feb 2021, 3:25 PM
Gajendra Jangid
Gajendra Jangid - avatar
+ 1
If you are still stuck at the problem then also no problem
2nd Feb 2021, 3:56 PM
Atul [Inactive]
+ 1
Thanks for helping but still it's not working😕
2nd Feb 2021, 5:04 PM
Gajendra Jangid
Gajendra Jangid - avatar