Repetition of k length substring
Easy Accuracy: 42.21% Submissions: 825 Points: 2

Given a string 's', your task is to complete the function checkString which returns true if it is possible to convert 's' to a string that is repetition of a substring with 'k' characters else returns false, where in order to convert we can replace one substring of length k with k characters.
 

Examples:

Input: str = "abcbedabcabc",  k = 3
Output: 1
Replace "bed" with "abc" so that the 
whole string becomes repetition of "abc".

Input: str = "bcacbcac", k = 2
Output: 0


Input:
The first line of input contains an integer T denoting the no of test cases. Then T test cases follow. Each test case contains 2 lines. The first line of each test case contains a string s. The second line of each test case contains an integer n.

Output:
For each test case in a new line output will be 1 if it is possible to convert the string else 0.

Constraints:
1<=T<=100
1< |Length of string| <=100
1<=N<=10

Example(To be used only for expected output):
Input:

2
abcbedabcabc
3
bcacbcac
2
Output:
1
0

 

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.