-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathstRotate2place.java
More file actions
74 lines (63 loc) · 1.82 KB
/
stRotate2place.java
File metadata and controls
74 lines (63 loc) · 1.82 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import java.util.*;
//rotate string2 by 2 place clock or anti to make equal to string 1
//facebook
//okfacebo
//true
class stRotate2place
{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String s1=sc.next();
String s2=sc.next();
//easy one
String a=s2.substring(2)+s2.substring(0,2);
String b=s2.substring(s2.length()-2,s2.length())+s2.substring(0,s2.length()-2);
System.out.println("CLOCK "+a);
System.out.println("ANTI CLOCK "+b);
if(a.equals(s1) || b.equals(s1))
{
System.out.println("YA");
}
else
{
System.out.println("NO");
}
// //another method
// //anticlockwise
// StringBuilder st=new StringBuilder();
// StringBuilder st1=new StringBuilder();
// StringBuilder st5=new StringBuilder();
// st5.append(s1);
// for(int i=0;i<s2.length()-2;i++)
// {
// st.append(s2.charAt(i));
// }
// for(int i=s2.length()-2;i<s2.length();i++)
// {
// st1.append(s2.charAt(i));
// }
// st1.append(st);
// System.out.println(st1);
// //clockwise
// StringBuilder st3=new StringBuilder();
// StringBuilder st4=new StringBuilder();
// for(int i=2;i<s2.length();i++)
// {
// st3.append(s2.charAt(i));
// }
// for(int i=0;i<2;i++)
// {
// st4.append(s2.charAt(i));
// }
// st3.append(st4);
// System.out.println(st3);
// if(st3.compareTo(st5)==0 || st1.compareTo(st5)==0)
// {
// System.out.println("TRUE");
// }
// else
// {
// System.out.println("FASLE");
// }
}
}