subject

Divisibility of Strings Given two strings, s and t, create a function that operates per the following rules:
1. Find whether string s is divisible by string t. String s divisible by string t if string t can be concatenated some number of times to obtain the string s.
If s is divisible, find the smallest string, u, such that it can be concatenated some number of times to obtain both s and t.
If it is not divisible, set the return value to -1.
2. Return the length of the string u or -1.
Example 1
s = 'bcdbcdbcdbcd'
t = 'bcdbcd'
If string tis concatenated twice, the result is 'bcdbcdbcdbcd' which is equal to the string s. The string s is divisible by string t. Since it passes the first test, look for the smallest string, u, that can be concatenated to create both strings sand t. The string 'bcd'is the smallest string that can be concatenated to create both strings sandt. The length of the string u is 3, which is the integer value to return.
Example 2
s="bcdbcdbcd"
t = "bcdbcd"
If string t is concatenated twice, the result is "bcdbcdbcdbcd" which is greater than ing s. There is an extra "bcd" in the concatenated string. The string s is not divisible by stringt, so return -1.
Function Description
Complete the function
findSmallestDivisor in the editor below. findSmallestDivisor has the following
parameter(s):
string s: a string
string t: a string
Returns:
int: the length of the smallest string, u, if string s is divisble by string t, or return -1 if not
• 1 s size of ss 2 x 105
• 1 s size of ts 2x105
• size of t s size of s
Input Format Format for Custom
Testing
Sample Case 0
Sample Input
STDIN Function

Irbblrbb arrow s = 'lrbblrbb'
Irbb arrowt = 'lrbb
Sample Output
4
Explanation
If string 'Irbb' is concatenated 2 times, the result is strings, so the string is divisible. If string 'rbb'is concatenated 1 time, the result is string t. The smallest string that can be concatenated some number of times to get both sand t is 'Irbb' with a length of 4.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 04:30
Ryan is working on the layout of her web page. she needs to figure out where her header, navigation bar, text, and images should go. what technique can her?
Answers: 1
question
Computers and Technology, 22.06.2019 15:20
This os integrated the processing power of windows nt with the easy-to-use gui of windows 98. windows 2000 windows 3.11 windows for workgroups windowa millennium edition
Answers: 1
question
Computers and Technology, 22.06.2019 21:00
Simon says is a memory game where "simon" outputs a sequence of 10 characters (r, g, b, y) and the user must repeat the sequence. create a for loop that compares the two strings starting from index 0. for each match, add one point to userscore. upon a mismatch, exit the loop using a break statement. assume simonpattern and userpattern are always the same length. ex: the following patterns yield a userscore of 4: simonpattern: rrgbryybgy userpattern: rrgbbrybgy
Answers: 2
question
Computers and Technology, 23.06.2019 01:30
For a typical middle-income family, what is the estimated cost of raising a child to the age of 18? $145,500 $245,340 $304,340 $455,500
Answers: 2
You know the right answer?
Divisibility of Strings Given two strings, s and t, create a function that operates per the followi...
Questions
question
Mathematics, 02.10.2020 08:01
question
Mathematics, 02.10.2020 08:01
question
Mathematics, 02.10.2020 08:01
question
Mathematics, 02.10.2020 08:01
Questions on the website: 13722361