题解 | #旋转字符串#
旋转字符串
https://www.nowcoder.com/practice/80b6bb8797644c83bc50ac761b72981c
using System; using System.Collections.Generic; class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * 旋转字符串 * @param A string字符串 * @param B string字符串 * @return bool布尔型 */ public bool solve (string A, string B) { // write code here if (string.IsNullOrWhiteSpace(B)) return true; if (string.IsNullOrWhiteSpace(A) && !string.IsNullOrWhiteSpace(B)) return false; List<string> listA = new List<string>(); for (int i = 0; i < A.Length; i++) { string strAL = A.Substring(0, i + 1); string strAR = A.Substring(i + 1, A.Length - i - 1); //listA.Add(strAL); //listA.Add(strAR); listA.Add(strAR + strAL); } return listA.FindIndex(r => r == B) >= 0 ? true : false; } }