码迷,mamicode.com
首页 > 其他好文 > 详细

1.8---字符串是否是旋转而成(CC150)

时间:2015-12-16 19:05:37      阅读:101      评论:0      收藏:0      [点我收藏+]

标签:

答案:利用了XY , YX中第一个XYXY包含了第二个

public class Solution{
    
    public static void main(String[] args){
        System.out.println(isRotation("abc","abc"));
    }
    public static boolean isSubstring(String str1,String str2){
        if(str1.contains(str2) || str2.contains(str1))    return true;
        
        
        return false;
    }
    public static boolean isRotation(String str1,String str2){
        if(str1.length() != str2.length()) return false;
        String sum = str1 + str1;
        return isSubstring(sum,str2);
    }
}

 

1.8---字符串是否是旋转而成(CC150)

标签:

原文地址:http://www.cnblogs.com/yueyebigdata/p/5051768.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!