image.png
    画重点:
    1.字符串连续重复k次出现,只需循环判断子字符串是否包含在字符串里,字符串的长度是否大于原字符串即可
    2.每次循环,字符串都要累加

    1. class Solution {
    2. public int maxRepeating(String sequence, String word) {
    3. int count = 0;
    4. String str = word;
    5. while(sequence.contains(str)&&str.length()<=sequence.length()){
    6. count++;
    7. str +=word;
    8. }
    9. return count;
    10. }
    11. }

    image.png
    哈哈哈哈,这个是不是说明我算法效率很高啊