docs:补充【0459.重复的子字符串.md】的 JavaScript 、C# 代码

This commit is contained in:
桜小路七葉
2024-12-27 14:48:22 +08:00
committed by GitHub
parent 2ea92f75c6
commit 5da4a7ec0e

View File

@ -648,6 +648,29 @@ var repeatedSubstringPattern = function (s) {
};
```
> 正则匹配
```javascript
/**
* @param {string} s
* @return {boolean}
*/
var repeatedSubstringPattern = function(s) {
let reg = /^(\w+)\1+$/
return reg.test(s)
};
```
> 移动匹配
```javascript
/**
* @param {string} s
* @return {boolean}
*/
var repeatedSubstringPattern = function (s) {
let ss = s + s;
return ss.substring(1, ss.length - 1).includes(s);
};
```
### TypeScript:
> 前缀表统一减一
@ -853,8 +876,10 @@ impl Solution {
}
```
### C#
> 前缀表不减一
```csharp
// 前缀表不减一
public bool RepeatedSubstringPattern(string s)
{
if (s.Length == 0)
@ -879,6 +904,13 @@ public int[] GetNext(string s)
}
```
> 移动匹配
```csharp
public bool RepeatedSubstringPattern(string s) {
string ss = (s + s).Substring(1, (s + s).Length - 2);
return ss.Contains(s);
}
```
<p align="center">
<a href="https://programmercarl.com/other/kstar.html" target="_blank">