String formation from substring
Submissions: 5375   Accuracy:

26.22%

  Difficulty: Medium   Marks: 4

Given a string ‘str’, check if it can be constructed by taking a substring of it and appending multiple copies of the substring together.  For example "abab" can be created by appending "ab" to "ab", but "abac" cannot be created by appending a substring to itself.

Input:
The first line contains T denoting the number of test cases. Then follows description of testcases. Each case contains a string.


Output:
For each test case, output "True" if it is possible and "False" if not.

 

Constraints:
1<=T<=100
1<=Length of String<=1000 

 

Example:
Input:
1
abcabcabc

Output:
True

Explanation :
The given string is 3 times repetition of "abc"

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

Author: Jaspreet Singh


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

to report an issue on this page.