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 13:30
Write lines of verse that rhyme to remember the following information: acid rain is a type of air pollution caused by chemicals in the air.
Answers: 1
question
Computers and Technology, 22.06.2019 17:00
Match the following. 1. show grouping of word processing tasks that can be performed quick access toolbar 2. shortcut location for commonly used elements scroll bars 3. organized commands used to modify documents ribbon 4. used to align and measure content in a word screen zoom bar 5. vertical and horizontal bars that are used to navigate through a document contextual tabs 6. displays the name of the document in use ruler 7. allows users to enlarge or shrink a visual of a word document title bar
Answers: 2
question
Computers and Technology, 23.06.2019 23:30
The keyboard usually has six rows of keys. which of the following is not one of the key group categories? letter keys number keys control keys graphic keys
Answers: 1
question
Computers and Technology, 24.06.2019 02:30
Write the pseudo code for this problem based on what you learned from the video. the purpose is to design a modular program that asks the user to enter a distance in kilometers, and then converts that distance to miles. the conversion formula is as follows: miles = kilometers x 0.6214
Answers: 3
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, 31.07.2019 22:30
Questions on the website: 13722367