459. Repeated Substring Pattern

Given a non-empty string check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. You may assume the given string consists of lowercase English letters only and its length will not exceed 10000.

Example 1:

Input:"abab"Output:TrueExplanation:It's the substring "ab" twice.

Example 2:

Input:"aba"Output:False

Example 3:

Input:"aaa"Output:True

刚开始只考虑了出现偶数次, 乐呵呵呵的觉得自己好牛逼 写出了别人都没想到的方法, 结果一跑test case 就傻逼了。 然后就看了大神们的算法。呵呵呵


459. Repeated Substring Pattern_第1张图片

你可能感兴趣的:(459. Repeated Substring Pattern)