MachineLearning
static boolean areRotations(String str1, String str2)
{
// There lengths must be same and str2 must be
// a substring of str1 concatenated with str1.
return (str1.length() == str2.length()) &&
((str1 + str1).indexOf(str2) != -1);
}
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upstatic boolean areRotations(String str1, String str2)
{
// There lengths must be same and str2 must be
// a substring of str1 concatenated with str1.
return (str1.length() == str2.length()) &&
((str1 + str1).indexOf(str2) != -1);
}