6 kyu
Repeated Substring
895 of 2,062opportunity356
Description:
For a given nonempty string s
find a minimum substring t
and the maximum number k
, such that the entire string s
is equal to t
repeated k
times.
The input string consists of lowercase latin letters.
Your function should return :
- a tuple
(t, k)
(in Python) - an array
[t, k]
(in Ruby and JavaScript) - in C, return
k
and write to the stringt
passed in parameter
Examples:
"ababab" ---> (t = "ab", k = 3)
"abcde" ---> (t = "abcde", k = 1)
because for this string, the minimum substring 't'
such that 's' is 'k' times 't', is 's' itself.
Algorithms
Similar Kata:
Stats:
Created | Dec 17, 2014 |
Published | Dec 17, 2014 |
Warriors Trained | 4168 |
Total Skips | 262 |
Total Code Submissions | 10191 |
Total Times Completed | 2062 |
Python Completions | 895 |
Ruby Completions | 461 |
JavaScript Completions | 743 |
C Completions | 30 |
COBOL Completions | 6 |
Total Stars | 77 |
% of votes with a positive feedback rating | 93% of 311 |
Total "Very Satisfied" Votes | 272 |
Total "Somewhat Satisfied" Votes | 36 |
Total "Not Satisfied" Votes | 3 |