Timer is Running

String formation from substring
Submissions: 76   Accuracy:

21.05%

  Difficulty: Medium   Marks: 4

Given a string ‘s’, the task is to check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. 

Example 1:

Input: s = "ababab"
Output: 1
Explanation: It is contructed by 
appending "ab" 3 times

Example 2:

Input: s = "ababac"
Output: 0
Explanation: Not possible to construct

User Task:
Your task is to complete the function isRepeat() which takes a single string as input and returns 1 if possible to construct, otherwise 0. You do not need to take any input or print anything.

Expected Time Complexity: O(|s|)
Expected Auxiliary Space: O(|s|)

Constraints:
1 <= |s| <= 105

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

Author: Jaspreet Singh


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.