Skip to content
This repository was archived by the owner on Dec 12, 2023. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions solutions/java/StringRotation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
public class StringRotation {

public static void main(String[] args) {
// TODO Auto-generated method stub
StringRotation sr = new StringRotation();
System.out.println(sr.isRotation("ABCD", "BCDA"));
}

public boolean isRotation(String one, String two) {
/**
* This code checks if one is a rotation of two The way it works is -
* concatenate the original string with itself, and check if the rotated
* string is contained in it. For example : ABCD is contained in BCDABCDA
*/
return (two + two).contains(one);
}
}