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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 09:40, Tyrant4life
It is vital to research each of the services you plan to disable before implementing any change, especially on critical machines such as the: a. servers in the test environment. b. domain controller and other infrastructure servers. c. desktops that have previously been attacked. d. desktops used by upper-level management.
Answers: 2
image
Computers and Technology, 23.06.2019 01:00, lusciousl
Petrică, tânăr licean în clasa a ix-a, a primit în dar de la părinţii săi un cont bancar pentru micile sale cheltuieli curente. el este pasionat de internet banking şi îşi verifică cu grijă toate tranzacţiile efectuate. pentru creşterea securităţii tranzacţiilor online, banca îi furnizează lui petrică un număr pe care el va trebui să îl modifice, obţinând un număr tan – număr de autentificare a tranzacţiei (transaction authentication number). regula de obţinere a numărului tan este următoarea: se formează cel mai mic număr par din toate cifrele numărului furnizat de bancă. cerinţă cunoscând numărul n furnizat de bancă, să se determine numărul tan obţinut de petrică. date de intrare fişierul tan. in conţine pe prima linie numărul natural n cu semnificaţia din enunţ. date de ieşire fişierul de ieşire tan. out va conţine o singură linie pe care va fi scris numărul tan cerut. restricţii • 0 < n < 18*1018 • n are cel puţin o cifră pară • numărul tan obţinut nu poate conţine zerouri nesemnificative
Answers: 2
image
Computers and Technology, 23.06.2019 05:00, bellad0124outlookcom
In cell b18, enter a formula to calculate the amount budgeted for meals. this amount is based on the daily meal allowance and the total travel days (# of nights+1).
Answers: 1
image
Computers and Technology, 23.06.2019 06:00, sebcbal
When is a chart legend used a. all the time b. whenever you are comparing data that is the same c. whenever you are comparing multiple sets of data d. only for hand-drawn charts
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 in other subjects: