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, 23.06.2019 09:00
Which company provides a crowdsourcing platform for corporate research and development? a: mtruk b: wiki answers c: mediawiki d: innocentive
Answers: 2
question
Computers and Technology, 23.06.2019 09:30
The place where the extended axis of the earth would touch the celestial sphere is called the celestial
Answers: 1
question
Computers and Technology, 24.06.2019 07:50
Write a defining table and then a program that determines if you can sleep in or not. your program should get all its input from your computer’s clock. on all weekdays (monday through friday) that are not holidays, your program should output “get up! ” on all other days (weekends and holidays), your program should output “sleep in.” the three holidays that your program must check for are january 1 (new year’s day), july 4 (u.s. independence day), and december 25 (christmas). you don’t need to include other holidays in your program because most other holidays do not occur on a fixed day each year.
Answers: 1
question
Computers and Technology, 24.06.2019 13:30
What is the most important for you to choose before you build a network?
Answers: 1
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, 05.03.2021 03:20
question
Biology, 05.03.2021 03:20
question
Mathematics, 05.03.2021 03:20
Questions on the website: 13722362