Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion problems/0459.重复的子字符串.md
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,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:

> 前缀表统一减一
Expand Down Expand Up @@ -894,8 +917,10 @@ impl Solution {
}
```
### C#

> 前缀表不减一

```csharp
// 前缀表不减一
public bool RepeatedSubstringPattern(string s)
{
if (s.Length == 0)
Expand All @@ -920,6 +945,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);
}
```
### C

```c
Expand Down