调试中...
调试中...
题目描述
题目描述
题解
题解
提交记录
提交记录
代码
代码
测试用例
测试用例
测试结果
测试结果
困难
相关标签
相关企业
提示

给你一个字符串 text ,请你返回满足下述条件的 不同 非空子字符串的数目:

  • 可以写成某个字符串与其自身相连接的形式(即,可以写为 a + a,其中 a 是某个字符串)。

例如,abcabc 就是 abc 和它自身连接形成的。

 

示例 1:

输入:text = "abcabcabc"
输出:3
解释:3 个子字符串分别为 "abcabc","bcabca" 和 "cabcab" 。

示例 2:

输入:text = "leetcodeleetcode"
输出:2
解释:2 个子字符串为 "ee" 和 "leetcodeleetcode" 。

 

提示:

  • 1 <= text.length <= 2000
  • text 只包含小写英文字母。
通过次数
7.3K
提交次数
13.9K
通过率
53.0%


相关企业

提示 1
Given a substring of the text, how to check if it can be written as the concatenation of a string with itself ?

提示 2
We can do that in linear time, a faster way is to use hashing.

提示 3
Try all substrings and use hashing to check them.


评论 (0)

贡献者
© 2025 领扣网络(上海)有限公司
0 人在线
行 1,列 1
text =
"abcabcabc"
Source