From 19a511c9ca4733ee4106c3240d101139f82c694c Mon Sep 17 00:00:00 2001 From: YanceyOfficial Date: Fri, 3 Nov 2023 18:51:59 +0800 Subject: [PATCH] feat: update --- leetcode-docs/hard/10-is-match.mdx | 2 +- leetcode-docs/hard/25-reverse-k-group.mdx | 13 ++++++------- leetcode-docs/hard/30-find-substring.mdx | 4 ++-- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/leetcode-docs/hard/10-is-match.mdx b/leetcode-docs/hard/10-is-match.mdx index 7745a156..c8008a93 100644 --- a/leetcode-docs/hard/10-is-match.mdx +++ b/leetcode-docs/hard/10-is-match.mdx @@ -111,7 +111,7 @@ var isMatch = function (s, p) { for (let i = 1; i <= m; i++) { for (let j = 1; j <= n; j++) { // 字母匹配上了, 或者 p 此时为 . 可能任意匹配, 状态从前一个转移过来即可 - if (p[j - 1] === s[i - 1] || p[j - 1] === '.') { + if (s[i - 1] === p[j - 1] || p[j - 1] === '.') { dp[i][j] = dp[i - 1][j - 1] // 如果遇到 *, 需要关注 * 前面那个 } else if (p[j - 1] === '*') { diff --git a/leetcode-docs/hard/25-reverse-k-group.mdx b/leetcode-docs/hard/25-reverse-k-group.mdx index 6c400351..097ff73c 100644 --- a/leetcode-docs/hard/25-reverse-k-group.mdx +++ b/leetcode-docs/hard/25-reverse-k-group.mdx @@ -83,15 +83,14 @@ var reverseKGroup = function (head, k) { * @return {ListNode} */ var reverse = function (a, b) { - let prev = null, - head = a + let prev = null // 在 a, b 区间翻转 - while (head !== b) { - const temp = head.next - head.next = prev - prev = head - head = temp + while (a !== b) { + const tmp = a.next + a.next = prev + prev = a + a = tmp } return prev diff --git a/leetcode-docs/hard/30-find-substring.mdx b/leetcode-docs/hard/30-find-substring.mdx index 3b5de442..c9ca2506 100644 --- a/leetcode-docs/hard/30-find-substring.mdx +++ b/leetcode-docs/hard/30-find-substring.mdx @@ -15,7 +15,7 @@ sidebar_label: 30. 串联所有单词的子串 :::note 提示: -- `1 <= s.length <= 104` +- `1 <= s.length <= 10⁴` - `1 <= words.length <= 5000` - `1 <= words[i].length <= 30` - `words[i]` 和 `s` 由小写英文字母组成 @@ -94,7 +94,7 @@ var findSubstring = function (s, words) { // 声明一个新的哈希表 subMap, 记录 subStr 中每 w 个小字符串 const subMap = new Map() - for (let j = 0; j < n * w; i += w) { + for (let j = 0; j < n * w; j += w) { const sub = subStr.slice(j, j + w) // 如果 words 中都没有子字符串, 可以提前终止