File tree Expand file tree Collapse file tree 1 file changed +33
-1
lines changed Expand file tree Collapse file tree 1 file changed +33
-1
lines changed Original file line number Diff line number Diff 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- // 前缀表不减一
858883public 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 " >
You can’t perform that action at this time.
0 commit comments