- 1
Has anyone solution to deja vu in java?
13 ответов
+ 3
If you have tried to solve the problem, then copy it and give it to me and I will help you.....😊
+ 2
Did you try to solve the problem
+ 1
The links you shared are private. Others can't see. Copy paste in playground and save, share link here.
So that helps you find if any mistakes..!
0
Check my code in python:
https://www.sololearn.com/coach/54?ref=app
0
it gives me an error
0
It's in python!!!
0
Sanoj first try it yourself if you have any doubts and then ask to someone they will help you
0
i tried for 1.5 hours
0
Oh ! Then where is your attempt 🤔 🙄 ?Sanoj
0
i will copy it tomorrow from my IDE
0
Here it is
s = str(input())
c= 0
for i in s:
n=s.count(i)
if n>1:
print("Deja Vu")
c=0
exit(0)
else:
c+=1
if c>0:
print("Unique")
0
I’ve spent more than 10 hours to solve “Deja Vu” task. It is my code. I wonder how to make it shorter and clear?
Scanner sc = new Scanner(System.in);
String words = sc.nextLine();
char [] letter = words.toCharArray();
int l = letter.length;
String res = "";
for (int y = 0; y<l-1; y++){
for (int i = y+1; i<l; i++){
if (letter[y] != letter[i]){
res = "Unique";
} else {
res = "Deja Vu";
break;
}
}
if (res.equals("Unique")){
continue;
} else {
break;
}
}
if (res.equals("Unique")){
System.out.println(res);
} else {
System.out.println("Deja Vu");
}
0
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String s = input.nextLine();
int counter = 0;
for(int i = 0; i< s.length(); i++) for(int j = s.length()-1; j>i; j--){
if(s.charAt(i) == s.charAt(j)){
counter++;
break;
}
}
if(counter > 0){
System.out.println("Deja Vu");
}else{
System.out.println("Unique");}
}
}