We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 88adb71 + d46e44e commit ba112c3Copy full SHA for ba112c3
solutions/java/StringRotation.java
@@ -0,0 +1,17 @@
1
+public class StringRotation {
2
+
3
+ public static void main(String[] args) {
4
+ // TODO Auto-generated method stub
5
+ StringRotation sr = new StringRotation();
6
+ System.out.println(sr.isRotation("ABCD", "BCDA"));
7
+ }
8
9
+ public boolean isRotation(String one, String two) {
10
+ /**
11
+ * This code checks if one is a rotation of two The way it works is -
12
+ * concatenate the original string with itself, and check if the rotated
13
+ * string is contained in it. For example : ABCD is contained in BCDABCDA
14
+ */
15
+ return (two + two).contains(one);
16
17
+}
0 commit comments