Skip to content

Commit a42fbfe

Browse files
yanglbmeidoocs
authored andcommitted
style: format code and docs with prettier
1 parent 5b534f7 commit a42fbfe

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

solution/3400-3499/3407.Substring Matching Pattern/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ tags:
8282

8383
### 方法一:字符串匹配
8484

85-
根据题目描述,'*' 可以被替换为零个或多个字符组成的任意字符序列,因此我们可以将模式字符串 $p$ 按照 `*` 分割成若干个子串,如果这些子串依次出现在字符串 $s$ 中且顺序不变,则说明 $p$ 可以变成 $s$ 的子字符串。
85+
根据题目描述,'_' 可以被替换为零个或多个字符组成的任意字符序列,因此我们可以将模式字符串 $p$ 按照 `_` 分割成若干个子串,如果这些子串依次出现在字符串 $s$ 中且顺序不变,则说明 $p$ 可以变成 $s$ 的子字符串。
8686

8787
因此,我们首先初始化一个指针 $i$ 指向字符串 $s$ 的起始位置,然后遍历模式字符串 $p$ 按照 `*` 分割得到的每个子串 $t$,在字符串 $s$ 中从位置 $i$ 开始查找子串 $t$,如果找到了,则将指针 $i$ 移动到子串 $t$ 的末尾位置继续查找下一个子串;如果找不到,则说明模式字符串 $p$ 不能变成字符串 $s$ 的子字符串,返回 $\text{false}$。如果所有子串都找到了,则返回 $\text{true}$。
8888

solution/3400-3499/3407.Substring Matching Pattern/README_EN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ tags:
8080

8181
### Solution 1: String Matching
8282

83-
According to the problem description, '*' can be replaced by any sequence of zero or more characters, so we can split the pattern string $p$ by `*` into several substrings. If these substrings appear in order in the string $s$, then $p$ can become a substring of $s$.
83+
According to the problem description, '_' can be replaced by any sequence of zero or more characters, so we can split the pattern string $p$ by `_` into several substrings. If these substrings appear in order in the string $s$, then $p$ can become a substring of $s$.
8484

8585
Therefore, we first initialize a pointer $i$ to the start of string $s$, then iterate over each substring $t$ obtained by splitting the pattern string $p$ by `*`. For each $t$, we search for it in $s$ starting from position $i$. If it is found, we move the pointer $i$ to the end of $t$ and continue searching for the next substring. If it is not found, it means the pattern string $p$ cannot become a substring of $s$, and we return $\text{false}$. If all substrings are found, we return $\text{true}$.
8686

0 commit comments

Comments
 (0)