-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTransform and Compare.java
More file actions
48 lines (41 loc) · 1.12 KB
/
Transform and Compare.java
File metadata and controls
48 lines (41 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String start=sc.next();
String end=sc.next();
if(start.length()!=end.length())
{
System.out.println("false");
return;
}
int flag=1;
for(int i=0;i<start.length()-1;i++)
{
char s1=start.charAt(i);
char s2=start.charAt(i+1);
char e1=end.charAt(i);
char e2=end.charAt(i+1);
if((s1==e2 && s2==e1)||(s1==e1 && s2==e2))
{
i++;
}
else if(s1==e1 && s2!=e2)
{
}
else
{
flag=0;
break;
}
}
if(flag==0)
{
System.out.println("false");
}
else
{
System.out.println("true");
}
}
}