-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRotation.java
More file actions
42 lines (33 loc) · 763 Bytes
/
Rotation.java
File metadata and controls
42 lines (33 loc) · 763 Bytes
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
public class Rotation {
public static void main(String[] args) {
// TODO Auto-generated method stub
String str1=new String("applemango");
String str2=new String("pleapp");
boolean flag=false;
String temp;
int i;
int len1=str1.length();
int len2=str2.length();
int len;
if(len1<len2)
len=len1;
else
len=len2;
//Concatenating the two strings
str1=str1+str1;
//Checking if other string is substring of the concatenated string or not
for(i=0;i<len;i++)
{
temp=str1.substring(i,i+str2.length());
if(temp.equals(str2))
flag=true;
}
//Base case testing
if(len1!=len2)
flag=false;
if(flag==true)
System.out.println("Rotation=true");
else
System.out.println("Rotation=false");
}
}