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;
}
}


posted @ 2015-02-17 06:37  江南第一少  阅读(141)  评论(0)    收藏  举报