欢迎访问悦橙教程(wld5.com),关注java教程。悦橙教程  java问答|  每日更新
页面导航 : > > 文章正文

is a rotation or not,rotationor,Assume you h

来源: javaer 分享于  点击 45196 次 点评:93

is a rotation or not,rotationor,Assume you h


Assume you have a method isSubstring which checks if one word is a substringof another.Given two strings, s1 and s2, write code to check if s2 is arotation of s1 using only one call to isSubstring (i.e., “waterbottle” is arotation of “erbottlewat”).

public static boolean isRotation(String a, String b) {    if (a.length() != b.length()) {        return false;    } else {        a = a + a;        return a.contains(b);    }}//该片段来自于http://byrx.net
相关栏目:

用户点评