Tap here to switch tabs
Problem
Submissions

Problem: Repeated String Match

med
30 min
Try to solve the Repeated String Match problem.

Statement

Given two strings a and b, return the minimum number of times a must be repeated so that b becomes a substring of the repeated string. If no number of repetitions of a can make b a substring, return -1.

Implement the method int repeatedStringMatch(str a, str b).

Constraints:

  • 1≤1 \leq a.length, b.length ≤104\leq 10^4

  • a and b consist of lowercase English letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Repeated String Match

med
30 min
Try to solve the Repeated String Match problem.

Statement

Given two strings a and b, return the minimum number of times a must be repeated so that b becomes a substring of the repeated string. If no number of repetitions of a can make b a substring, return -1.

Implement the method int repeatedStringMatch(str a, str b).

Constraints:

  • 1≤1 \leq a.length, b.length ≤104\leq 10^4

  • a and b consist of lowercase English letters.