-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathProblem-2.java
44 lines (31 loc) · 867 Bytes
/
Problem-2.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
37
38
39
40
41
42
43
44
/**
* @author AkashGoyal
* @date 10/06/2021
*/
/**
--------------------- Problem----------->> Write a Code to check whether one string is a rotation of another
Problem Link :- https://practice.geeksforgeeks.org/problems/check-if-strings-are-rotations-of-each-other-or-not-1587115620/1
*/
class Solution
{
//Function to check if two strings are rotations of each other or not.
public static boolean areRotations(String s1, String s2 )
{
// Your code here
StringBuilder sb=new StringBuilder();
sb.append(s1);
sb.append(s1);
if(s1.length()!=s2.length())
{
return false;
}
if(sb.toString().contains(s2))
{
return true;
}
else
{
return false;
}
}
}