Repetition of k length substring
Submissions: 510   Accuracy:

41.79%

  Difficulty: Easy   Marks: 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

 

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Harshit Sidhwa
Author: Shubham Joshi 1


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.