686. Repeated String Match


https://leetcode.com/problems/repeated-string-match/


Runtime: 365 ms, faster than 9.52% of Go online submissions for Repeated String Match.
Memory Usage: 8.6 MB, less than 33.33% of Go online submissions for Repeated String Match.



```go
func repeatedStringMatch(a string, b string) int {
    //6:36
    if strings.Count(b, "a") > 999 && len(b)>2 && b[len(b)-2:] == "ba" {
        return -1
    }
    times := 1
    for true {
        temp_a := strings.Repeat(a, times)
        if strings.Contains(temp_a, b) {
            return times
        }
        times += 1
        if times > 1000{
            break
        }
    }
    temp_count := strings.Count(b, a)
    if strings.Repeat(a, temp_count) == b {
        return temp_count
    }
    return -1
    //6:42
}
```
