Given a string, find if it is possible to convert it to a string that is repetition of substring with k characters. To convert, we can replace one substring of length k with k characters.
The first line of input contains an integer T denoting the no of test cases. Then T test cases follow. Each test case contains an integer N, denoting the length of the string. Next line contains the string. Third line contains an integer k denoting the length of the substrings.
For each test case in a new line output will be 1/0 if true else false.
1<= T <= 100
2<= k < N <=50
Test Case 1 -
We can either replace "bd" with "ac" or "ac" with "bd".
Test Case 2 -
Replace "bed" with "abc" so that the whole string becomes repetition of "abc".
Test Case 3 -
k doesn't divide string length i.e. 5%3 != 0
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.