Given a string A
consisting of n
characters and a string B
consisting of m
characters, write a function that will return the number of times A
must be stated such that B
is a substring of the repeated A
. If B
can never be a substring, return -1
.
WhenA = ‘abcd’
and B = ‘cdabcdab’
, the output should be 3
. Because after stating A
3 times, getting ‘abcdabcdabcd’
, B
is now a substring of A
.
WhenA = ‘abcd’
and B = ‘cdadab’
, the output should be -1
. BecauseB
can never be a substring of A
.