+ 1
Can anyone tell the 5th test case?
What is the 5th test case of Deja Vu?
7 Antworten
+ 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.
+ 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
+ 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
+ 1
Just paste your code here
+ 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");
}
}
}
+ 1
If you are still stuck at the problem then also no problem
+ 1
Thanks for helping but still it's not working😕