CC150 : Check String Rotation
Given isSubstring() which checks if one word is a substring of another, write code to check if s2 is a rotation of s1.
class Solution {
public boolean isRotation(String s1, String s2) {
if(s1.length() > 0 && s1.length()== s2.length()) {
String s1s1 = s1 + s1;
return isSubstring(s1s1, s2);
}
return false;
}
}

浙公网安备 33010602011771号