
a는 b보다 길거나 같아야 부분 문자열로 포함 가능하므로 최소 필요한 반복 횟수 조회b가 포함되는지 확인[ a b c d ] [ a b c d ] [ a b c d ]
|___________________________|-1 반환function repeatedStringMatch(a: string, b: string): number {
const minRepeat = Math.ceil(b.length / a.length)
if(a.repeat(minRepeat).includes(b)) {
return minRepeat
}
if(a.repeat(minRepeat + 1).includes(b)) {
return minRepeat + 1
}
return -1
};