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

1.8 Is Rotation

时间:2014-11-21 15:51:15      阅读:232      评论:0      收藏:0      [点我收藏+]

标签:style   blog   io   color   sp   on   div   log   bs   

Assume you have a method isSubstring which checks if one word is a
substring of another. Given two strings, s1 and s2, write code to check if s2 is
a rotation of s1 using only one call to isSubstring (e.g.,"waterbottle"is a rotation
of "erbottlewat").

1 public static boolean isRotation(String s1, String s2) {
2     if(s1 == null || s2 == null)    return false;
3     if(s1.length() != s2.length())    return false;
4 
5     String s3 = s1 + s1;
6     return isSubstring(s3, s2);
7 }

 

1.8 Is Rotation

标签:style   blog   io   color   sp   on   div   log   bs   

原文地址:http://www.cnblogs.com/superbo/p/4112790.html

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