Write a program to check if one String is a rotation of another String is a common coding problem you will see on programming job interviews. A String is said to be a rotation of another String, if it has the same length, contains same characters, and they were rotated around one of the characters. For example, String"bcda" is a rotation of "abcd" but "bdca" is not a rotation of String "abcd". One of the simplest solutions to this interesting problem is first to check if two String has the same length, if not then one String cannot be the rotation of another. If they are of the same length then just create another String by concatenating first String with itself, now check if second String is a substring of this concatenated String or not, if yes, then second String is a rotation of first.
Read more »This post first appeared on Javarevisited: Blog About Java Programmin, please read the originial post: here