2017.9.28
首先判断两个字符串的长度是不是相同。然后判断,字符串A两个进行拼接后,是不是包含着字符串B,就表示是不是循环单词了
public class Solution {
/*
* @param words: A list of words
* @return: Return how many different rotate words
*/
public int countRotateWords(List<String> words){
int size = words.size();
if(size <= 1){
return size;
}
String []tmp = new String[size];
int count = 0;
for(String s : words){
boolean flag = false;
for(int i = 0; i <= count; i++){
if(tmp[i] != null && tmp[i].length() == s.length()*2 && tmp[i].contains(s)){
flag = true;
break;
}
}
if(flag == false){
String add = s+s;
tmp[count] = add;
count++;
}
}
return count;
}
}