Rotate String
看一个字符串B不是左旋后的A. 只需要把A复制一下, 然后看其中有没有B即可.
1 2 3 4 5 6 7 8 9 10 11 12 |
class Solution { public boolean rotateString(String A, String B) { if(A.length() != B.length()) // must has same length return false; else { String C = A + A; if(C.contains(B))// rotate and same return true; } return false; } } |