459.重复的子字符串
小于 1 分钟
459.重复的子字符串
/*
* @lc app=leetcode.cn id=459 lang=typescript
*
* [459] 重复的子字符串
*/
// @lc code=start
function repeatedSubstringPattern(s: string): boolean {
let newStr = s + s;
// 如果 s 是一个重复的子串模式,那么 s 必然可以表示为某个更短的字符串 t 重复若干次。
return newStr.slice(1, newStr.length - 1).includes(s);
}
console.log(repeatedSubstringPattern("abaababaab"));
// @lc code=end
Loading...
