Algorithms-Puzzles/RepeatedSubstring.md at master · kuldeepiitg/Algorithms-Puzzles
Given an input string S write a function which returns true if it satisfies S = nT. Basically you have to find if a given string can be represented from a substring by iterating it "n" times. n >= 2
Function should return true if
1) S = "abab"
2) S = "abcdabcd"
3) S = "abcabcabc"
4) S = "zzxzzxzzx"
Function should return false if
1) S = "abac"
2) S = "abcdabbd"
3) S = "abcabcefg"
4) S = "zzxzzyzzx"
Algorithm :
Start writing substring from start. If next coming substring is not matching then concatenate it with existing.
Read full article from Algorithms-Puzzles/RepeatedSubstring.md at master · kuldeepiitg/Algorithms-Puzzles
No comments:
Post a Comment