-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfakepassword.java
36 lines (34 loc) · 1.18 KB
/
fakepassword.java
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
import java.util.*;
import java.io.*;
public class fakepassword {
public static void main(String[] args)throws IOException {
Scanner sc= new Scanner(System.in);
int t = sc.nextInt();
sc.nextLine();
while (t-- > 0)
{
String original=sc.next();
String fake=sc.next();
password(original, fake);
}
}
private static void password(String original, String fake) {
int start = 0;
int last = fake.length() - 2;
int length = fake.length();
int front = length - last;
String first = fake.substring(start, front);
String firstHalf = fake.substring(front, length);
String second = fake.substring(last, length);
String secondHalf = fake.substring(start, last);
String temp1 = second.concat(secondHalf);
String temp2 = firstHalf.concat(first);
// System.out.println(temp1);
//System.out.println(temp2);
if (temp1.compareTo(original) == 0 || temp2.compareTo(original) == 0) {
System.out.println("Yes");
} else {
System.out.println("No");
}
}
}