Skip to content

Commit 5da4a7e

Browse files
authored
docs:补充【0459.重复的子字符串.md】的 JavaScript 、C# 代码
1 parent 2ea92f7 commit 5da4a7e

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

problems/0459.重复的子字符串.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,29 @@ var repeatedSubstringPattern = function (s) {
648648
};
649649
```
650650

651+
> 正则匹配
652+
```javascript
653+
/**
654+
* @param {string} s
655+
* @return {boolean}
656+
*/
657+
var repeatedSubstringPattern = function(s) {
658+
let reg = /^(\w+)\1+$/
659+
return reg.test(s)
660+
};
661+
```
662+
> 移动匹配
663+
```javascript
664+
/**
665+
* @param {string} s
666+
* @return {boolean}
667+
*/
668+
var repeatedSubstringPattern = function (s) {
669+
let ss = s + s;
670+
return ss.substring(1, ss.length - 1).includes(s);
671+
};
672+
```
673+
651674
### TypeScript:
652675

653676
> 前缀表统一减一
@@ -853,8 +876,10 @@ impl Solution {
853876
}
854877
```
855878
### C#
879+
880+
> 前缀表不减一
881+
856882
```csharp
857-
// 前缀表不减一
858883
public bool RepeatedSubstringPattern(string s)
859884
{
860885
if (s.Length == 0)
@@ -879,6 +904,13 @@ public int[] GetNext(string s)
879904
}
880905
```
881906

907+
> 移动匹配
908+
```csharp
909+
public bool RepeatedSubstringPattern(string s) {
910+
string ss = (s + s).Substring(1, (s + s).Length - 2);
911+
return ss.Contains(s);
912+
}
913+
```
882914

883915
<p align="center">
884916
<a href="https://programmercarl.com/other/kstar.html" target="_blank">

0 commit comments

Comments
 (0)