is a rotation or not,rotationor,Assume you h
分享于 点击 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
用户点评