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

chore: update lc problems #1588

Merged
merged 2 commits into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
const isEn = () => location.hash.includes('README_EN');
const isRoot = () => ['', '#/', '#/README', '#/README_EN'].includes(location.hash);
const sidebar = () => isRoot() ? false : (isEn() ? 'summary_en.md' : 'summary.md');
const cleanedHtml = (html) => {
return html.replace(/<pre>([\s\S]*?)<\/pre>/g, function (match, group) {
return "<pre>" + group.replace(/<code>([\s\S]*?)<\/code>/g, "$1") + "</pre>";
});
};

window.addEventListener('hashchange', () => {
window.$docsify.loadSidebar = sidebar();
Expand Down Expand Up @@ -111,6 +116,7 @@

const github = `[GitHub](${url})`
const gitee = `[Gitee](${url.replace("github", "gitee")})`
html = cleanedHtml(html);
const editHtml = isEn() ? `:memo: Edit on ${github} / ${gitee}\n` : `:memo: 在 ${github} / ${gitee} 编辑\n`
return editHtml + html
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,24 @@
<pre>
<strong>输入: </strong>s = "abcabcbb"
<strong>输出: </strong>3
<strong>解释:</strong> 因为无重复字符的最长子串是 "abc",所以其长度为 3。
<strong>解释:</strong> 因为无重复字符的最长子串是 <code>"abc"</code>,所以其长度为 3。
</pre>

<p><strong>示例 2:</strong></p>

<pre>
<strong>输入: </strong>s = "bbbbb"
<strong>输出: </strong>1
<strong>解释: </strong>因为无重复字符的最长子串是 "b",所以其长度为 1。
<strong>解释: </strong>因为无重复字符的最长子串是 <code>"b"</code>,所以其长度为 1。
</pre>

<p><strong>示例 3:</strong></p>

<pre>
<strong>输入: </strong>s = "pwwkew"
<strong>输出: </strong>3
<strong>解释: </strong>因为无重复字符的最长子串是 "wke",所以其长度为 3。
请注意,你的答案必须是 <strong>子串 </strong>的长度,"pwke" 是一个<em>子序列,</em>不是子串。
<strong>解释: </strong>因为无重复字符的最长子串是&nbsp;<code>"wke"</code>,所以其长度为 3。
&nbsp; 请注意,你的答案必须是 <strong>子串 </strong>的长度,<code>"pwke"</code>&nbsp;是一个<em>子序列,</em>不是子串。
</pre>

<p>&nbsp;</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
<li>例如,如果&nbsp;<code>words = ["ab","cd","ef"]</code>, 那么&nbsp;<code>"abcdef"</code>,&nbsp;<code>"abefcd"</code>,<code>"cdabef"</code>,&nbsp;<code>"cdefab"</code>,<code>"efabcd"</code>, 和&nbsp;<code>"efcdab"</code> 都是串联子串。&nbsp;<code>"acdbef"</code> 不是串联子串,因为他不是任何&nbsp;<code>words</code>&nbsp;排列的连接。</li>
</ul>

<p>返回所有串联字串在&nbsp;<code>s</code><strong>&nbsp;</strong>中的开始索引。你可以以 <strong>任意顺序</strong> 返回答案。</p>
<p>返回所有串联子串在&nbsp;<code>s</code><strong>&nbsp;</strong>中的开始索引。你可以以 <strong>任意顺序</strong> 返回答案。</p>

<p>&nbsp;</p>

<p><strong>示例 1:</strong></p>

<pre>
<strong>输入:</strong>s = "barfoothefoobarman", words = ["foo","bar"]
<strong>输出:</strong>[0,9]
<strong>输出:</strong><code>[0,9]</code>
<strong>解释:</strong>因为 words.length == 2 同时 words[i].length == 3,连接的子字符串的长度必须为 6。
子串 "barfoo" 开始位置是 0。它是 words 中以 ["bar","foo"] 顺序排列的连接。
子串 "foobar" 开始位置是 9。它是 words 中以 ["foo","bar"] 顺序排列的连接。
Expand All @@ -33,7 +33,7 @@

<pre>
<strong>输入:</strong>s = "wordgoodgoodgoodbestword", words = ["word","good","best","word"]
<strong>输出:</strong>[]
<code><strong>输出:</strong>[]</code>
<strong>解释:</strong>因为<strong> </strong>words.length == 4 并且 words[i].length == 4,所以串联子串的长度必须为 16。
s 中没有子串长度为 16 并且等于 words 的任何顺序排列的连接。
所以我们返回一个空数组。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ The output order does not matter. Returning [9,0] is fine too.
<strong>Input:</strong> s = &quot;wordgoodgoodgoodbestword&quot;, words = [&quot;word&quot;,&quot;good&quot;,&quot;best&quot;,&quot;word&quot;]
<strong>Output:</strong> []
<strong>Explanation:</strong> Since words.length == 4 and words[i].length == 4, the concatenated substring has to be of length 16.
There is no substring of length 16 is s that is equal to the concatenation of any permutation of words.
There is no substring of length 16 in s that is equal to the concatenation of any permutation of words.
We return an empty array.
</pre>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
<p><strong>示例 1:</strong></p>

<pre>
<strong>输入:</strong>nums = [4,5,6,7,0,1,2], target = 0
<strong>输入:</strong>nums = [<code>4,5,6,7,0,1,2]</code>, target = 0
<strong>输出:</strong>4
</pre>

<p><strong>示例&nbsp;2:</strong></p>

<pre>
<strong>输入:</strong>nums = [4,5,6,7,0,1,2], target = 3
<strong>输入:</strong>nums = [<code>4,5,6,7,0,1,2]</code>, target = 3
<strong>输出:</strong>-1</pre>

<p><strong>示例 3:</strong></p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
<p><strong>示例 1:</strong></p>

<pre>
<strong>输入:</strong>nums = [5,7,7,8,8,10], target = 8
<strong>输入:</strong>nums = [<code>5,7,7,8,8,10]</code>, target = 8
<strong>输出:</strong>[3,4]</pre>

<p><strong>示例&nbsp;2:</strong></p>

<pre>
<strong>输入:</strong>nums = [5,7,7,8,8,10], target = 6
<strong>输入:</strong>nums = [<code>5,7,7,8,8,10]</code>, target = 6
<strong>输出:</strong>[-1,-1]</pre>

<p><strong>示例 3:</strong></p>
Expand Down
8 changes: 4 additions & 4 deletions solution/0000-0099/0038.Count and Say/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
4. 1211
5. 111221
第一项是数字 1
描述前一项,这个数是 1 即 “ 一 个 1 ”,记作 "11"
描述前一项,这个数是 11 即 “ 二 个 1 ” ,记作 "21"
描述前一项,这个数是 21 即 “ 一 个 2 + 一 个 1 ” ,记作 "1211"
描述前一项,这个数是 1211 即 “ 一 个 1 + 一 个 2 + 二 个 1 ” ,记作 "111221"
描述前一项,这个数是 <code>1</code> 即 “ 一 个 1 ”,记作 <code>"11"
</code>描述前一项,这个数是 <code>11</code> 即 “ 二 个 1 ” ,记作 <code>"21"
</code>描述前一项,这个数是 <code>21</code> 即 “ 一 个 2 + 一 个 1 ” ,记作 "<code>1211"
</code>描述前一项,这个数是 <code>1211</code> 即 “ 一 个 1 + 一 个 2 + 二 个 1 ” ,记作 "<code>111221"</code>
</pre>

<p>要 <strong>描述</strong> 一个数字字符串,首先要将字符串分割为 <strong>最小</strong> 数量的组,每个组都由连续的最多 <strong>相同字符</strong> 组成。然后对于每个组,先描述字符的数量,然后描述字符,形成一个描述组。要将描述转换为数字字符串,先将每组中的字符数量用数字替换,再将所有描述组连接起来。</p>
Expand Down
6 changes: 3 additions & 3 deletions solution/0000-0099/0039.Combination Sum/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<p><strong>示例&nbsp;1:</strong></p>

<pre>
<strong>输入:</strong>candidates = [2,3,6,7], target = 7
<strong>输入:</strong>candidates = <code>[2,3,6,7], </code>target = <code>7</code>
<strong>输出:</strong>[[2,2,3],[7]]
<strong>解释:</strong>
2 和 3 可以形成一组候选,2 + 2 + 3 = 7 。注意 2 可以使用多次。
Expand All @@ -27,13 +27,13 @@
<p><strong>示例&nbsp;2:</strong></p>

<pre>
<strong>输入: </strong>candidates = [2,3,5], target = 8
<strong>输入: </strong>candidates = [2,3,5]<code>, </code>target = 8
<strong>输出: </strong>[[2,2,2,2],[2,3,3],[3,5]]</pre>

<p><strong>示例 3:</strong></p>

<pre>
<strong>输入: </strong>candidates = [2], target = 1
<strong>输入: </strong>candidates = <code>[2], </code>target = 1
<strong>输出: </strong>[]
</pre>

Expand Down
2 changes: 1 addition & 1 deletion solution/0000-0099/0040.Combination Sum II/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<p><strong>示例&nbsp;1:</strong></p>

<pre>
<strong>输入:</strong> candidates =&nbsp;[10,1,2,7,6,1,5], target =&nbsp;8,
<strong>输入:</strong> candidates =&nbsp;<code>[10,1,2,7,6,1,5]</code>, target =&nbsp;<code>8</code>,
<strong>输出:</strong>
[
[1,1,6],
Expand Down
2 changes: 1 addition & 1 deletion solution/0000-0099/0057.Insert Interval/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<pre>
<strong>输入:</strong>intervals = [[1,2],[3,5],[6,7],[8,10],[12,16]], newInterval = [4,8]
<strong>输出:</strong>[[1,2],[3,10],[12,16]]
<strong>解释:</strong>这是因为新的区间 [4,8] 与 [3,5],[6,7],[8,10] 重叠。</pre>
<strong>解释:</strong>这是因为新的区间 <code>[4,8]</code><code>[3,5],[6,7],[8,10]</code> 重叠。</pre>

<p><strong>示例 3:</strong></p>

Expand Down
30 changes: 15 additions & 15 deletions solution/0100-0199/0115.Distinct Subsequences/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,26 @@
<p><strong>示例&nbsp;1:</strong></p>

<pre>
<strong>输入:</strong>s = "rabbbit", t = "rabbit"
<strong>输出</strong><strong>:</strong>3
<strong>解释:</strong>
如下所示, 有 3 种可以从 s 中得到 "rabbit" 的方案。
<strong><u>rabb</u></strong>b<strong><u>it</u></strong>
<strong><u>ra</u></strong>b<strong><u>bbit</u></strong>
<strong><u>rab</u></strong>b<strong><u>bit</u></strong></pre>
<strong>输入:</strong>s = "rabbbit", t = "rabbit"<code>
<strong>输出</strong></code><strong>:</strong><code>3
</code><strong>解释:</strong>
如下所示, 有 3 种可以从 s 中得到 <code>"rabbit" 的方案</code>
<code><strong><u>rabb</u></strong>b<strong><u>it</u></strong></code>
<code><strong><u>ra</u></strong>b<strong><u>bbit</u></strong></code>
<code><strong><u>rab</u></strong>b<strong><u>bit</u></strong></code></pre>

<p><strong>示例&nbsp;2:</strong></p>

<pre>
<strong>输入:</strong>s = "babgbag", t = "bag"
<strong>输出</strong><strong>:</strong>5
<strong>解释:</strong>
如下所示, 有 5 种可以从 s 中得到 "bag" 的方案。
<strong><u>ba</u></strong>b<u><strong>g</strong></u>bag
<strong><u>ba</u></strong>bgba<strong><u>g</u></strong>
<u><strong>b</strong></u>abgb<strong><u>ag</u></strong>
ba<u><strong>b</strong></u>gb<u><strong>ag</strong></u>
babg<strong><u>bag</u></strong>
<code><strong>输出</strong></code><strong>:</strong><code>5
</code><strong>解释:</strong>
如下所示, 有 5 种可以从 s 中得到 <code>"bag" 的方案</code>
<code><strong><u>ba</u></strong>b<u><strong>g</strong></u>bag</code>
<code><strong><u>ba</u></strong>bgba<strong><u>g</u></strong></code>
<code><u><strong>b</strong></u>abgb<strong><u>ag</u></strong></code>
<code>ba<u><strong>b</strong></u>gb<u><strong>ag</strong></u></code>
<code>babg<strong><u>bag</u></strong></code>
</pre>

<p>&nbsp;</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<pre>
<strong>输入:</strong>nums = [100,4,200,1,3,2]
<strong>输出:</strong>4
<strong>解释:</strong>最长数字连续序列是 [1, 2, 3, 4]。它的长度为 4。</pre>
<strong>解释:</strong>最长数字连续序列是 <code>[1, 2, 3, 4]。它的长度为 4。</code></pre>

<p><strong>示例 2:</strong></p>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@

<pre><strong>输入:</strong> root = [6,2,8,0,4,7,9,null,null,3,5], p = 2, q = 8
<strong>输出:</strong> 6
<strong>解释: </strong>节点 2 和节点 8 的最近公共祖先是 6。
<strong>解释: </strong>节点 <code>2 </code>和节点 <code>8 </code>的最近公共祖先是 <code>6。</code>
</pre>

<p><strong>示例 2:</strong></p>

<pre><strong>输入:</strong> root = [6,2,8,0,4,7,9,null,null,3,5], p = 2, q = 4
<strong>输出:</strong> 2
<strong>解释: </strong>节点 2 和节点 4 的最近公共祖先是 2, 因为根据定义最近公共祖先节点可以为节点本身。</pre>
<strong>解释: </strong>节点 <code>2</code> 和节点 <code>4</code> 的最近公共祖先是 <code>2</code>, 因为根据定义最近公共祖先节点可以为节点本身。</pre>

<p>&nbsp;</p>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
<pre>
<strong>输入:</strong>root = [3,5,1,6,2,0,8,null,null,7,4], p = 5, q = 1
<strong>输出:</strong>3
<strong>解释:</strong>节点 5 和节点 1 的最近公共祖先是节点 3 。
<strong>解释:</strong>节点 <code>5 </code>和节点 <code>1 </code>的最近公共祖先是节点 <code>3 。</code>
</pre>

<p><strong>示例 2:</strong></p>
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0200-0299/0236.Lowest%20Common%20Ancestor%20of%20a%20Binary%20Tree/images/binarytree.png" style="width: 200px; height: 190px;" />
<pre>
<strong>输入:</strong>root = [3,5,1,6,2,0,8,null,null,7,4], p = 5, q = 4
<strong>输出:</strong>5
<strong>解释:</strong>节点 5 和节点 4 的最近公共祖先是节点 5 。因为根据定义最近公共祖先节点可以为节点本身。
<strong>解释:</strong>节点 <code>5 </code>和节点 <code>4 </code>的最近公共祖先是节点 <code>5 。</code>因为根据定义最近公共祖先节点可以为节点本身。
</pre>

<p><strong>示例 3:</strong></p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
<p><strong>示例 1:</strong></p>

<pre>
<strong>输入:</strong> nums = [1,2,3,4]
<strong>输出:</strong> [24,12,8,6]
<strong>输入:</strong> nums = <code>[1,2,3,4]</code>
<strong>输出:</strong> <code>[24,12,8,6]</code>
</pre>

<p><strong>示例 2:</strong></p>
Expand Down
4 changes: 2 additions & 2 deletions solution/0200-0299/0258.Add Digits/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
<p><strong>示例 1:</strong></p>

<pre>
<strong>输入:</strong> num =<strong> </strong>38
<strong>输入:</strong> num =<strong> </strong><code>38</code>
<strong>输出:</strong> 2
<strong>解释: </strong>各位相加的过程为<strong>:
</strong>38 --&gt; 3 + 8 --&gt; 11
11 --&gt; 1 + 1 --&gt; 2
由于&nbsp;2 是一位数,所以返回 2。
由于&nbsp;<code>2</code> 是一位数,所以返回 2。
</pre>

<p><strong>示例 2:</strong></p>
Expand Down
6 changes: 3 additions & 3 deletions solution/0200-0299/0259.3Sum Smaller/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<p><strong>示例 1:</strong></p>

<pre>
<strong>输入: </strong><em>nums</em> = [-2,0,1,3], <em>target</em> = 2
<strong>输入: </strong><em>nums</em> = <code>[-2,0,1,3]</code>, <em>target</em> = 2
<strong>输出: </strong>2
<strong>解释: </strong>因为一共有两个三元组满足累加和小于 2:
&nbsp; [-2,0,1]
Expand All @@ -23,13 +23,13 @@
<p><strong>示例 2:</strong></p>

<pre>
<strong>输入: </strong><em>nums</em> = [], <em>target</em> = 0
<strong>输入: </strong><em>nums</em> = <code>[]</code>, <em>target</em> = 0
<strong>输出: </strong>0 </pre>

<p><strong>示例 3:</strong></p>

<pre>
<strong>输入: </strong><em>nums</em> = [0], <em>target</em> = 0
<strong>输入: </strong><em>nums</em> = <code>[0]</code>, <em>target</em> = 0
<strong>输出: </strong>0 </pre>

<p>&nbsp;</p>
Expand Down
4 changes: 2 additions & 2 deletions solution/0200-0299/0261.Graph Valid Tree/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
<p><img src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0200-0299/0261.Graph%20Valid%20Tree/images/tree1-graph.jpg" /></p>

<pre>
<strong>输入:</strong> n = 5, edges = [[0,1],[0,2],[0,3],[1,4]]
<strong>输入:</strong> <code>n = 5</code>, edges<code> = [[0,1],[0,2],[0,3],[1,4]]</code>
<strong>输出:</strong> true</pre>

<p><strong>示例 2:</strong></p>

<p><img src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0200-0299/0261.Graph%20Valid%20Tree/images/tree2-graph.jpg" /></p>

<pre>
<strong>输入:</strong> n = 5, edges = [[0,1],[1,2],[2,3],[1,3],[1,4]]
<strong>输入:</strong> <code>n = 5, </code>edges<code> = [[0,1],[1,2],[2,3],[1,3],[1,4]]</code>
<strong>输出:</strong> false</pre>

<p>&nbsp;</p>
Expand Down
2 changes: 1 addition & 1 deletion solution/0200-0299/0263.Ugly Number/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<pre>
<strong>输入:</strong>n = 14
<strong>输出:</strong>false
<strong>解释:</strong>14 不是丑数,因为它包含了另外一个质因数&nbsp;7
<strong>解释:</strong>14 不是丑数,因为它包含了另外一个质因数&nbsp;<code>7 </code>
</pre>

<p>&nbsp;</p>
Expand Down
6 changes: 3 additions & 3 deletions solution/0200-0299/0266.Palindrome Permutation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@

<p><strong>示例 1:</strong></p>

<pre><strong>输入:</strong> &quot;code&quot;
<pre><strong>输入:</strong> <code>&quot;code&quot;</code>
<strong>输出:</strong> false</pre>

<p><strong>示例 2:</strong></p>

<pre><strong>输入:</strong> &quot;aab&quot;
<pre><strong>输入:</strong> <code>&quot;aab&quot;</code>
<strong>输出:</strong> true</pre>

<p><strong>示例 3:</strong></p>

<pre><strong>输入:</strong> &quot;carerac&quot;
<pre><strong>输入:</strong> <code>&quot;carerac&quot;</code>
<strong>输出:</strong> true</pre>

## 解法
Expand Down
8 changes: 4 additions & 4 deletions solution/0200-0299/0267.Palindrome Permutation II/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
<p><strong>示例 1:</strong></p>

<pre>
<strong>输入: </strong>s = "aabb"
<strong>输出: </strong>["abba", "baab"]></pre>
<strong>输入: </strong>s = <code>"aabb"</code>
<strong>输出: </strong><code>["abba", "baab"]</code></pre>

<p><strong>示例 2:</strong></p>

<pre>
<strong>输入: </strong>s = "abc"
<strong>输出: </strong>[]
<strong>输入: </strong>s = <code>"abc"</code>
<strong>输出: </strong><code>[]</code>
</pre>

<p>&nbsp;</p>
Expand Down
2 changes: 1 addition & 1 deletion solution/0200-0299/0269.Alien Dictionary/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<pre>
<strong>输入:</strong>words = ["z","x","z"]
<strong>输出:</strong>""
<strong>解释:</strong>不存在合法字母顺序,因此返回 "" 。
<strong>解释:</strong>不存在合法字母顺序,因此返回 <code>"" 。</code>
</pre>

<p>&nbsp;</p>
Expand Down
2 changes: 1 addition & 1 deletion solution/0200-0299/0269.Alien Dictionary/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<pre>
<strong>Input:</strong> words = [&quot;z&quot;,&quot;x&quot;,&quot;z&quot;]
<strong>Output:</strong> &quot;&quot;
<strong>Explanation:</strong> The order is invalid, so return &quot;&quot;.
<strong>Explanation:</strong> The order is invalid, so return <code>&quot;&quot;</code>.
</pre>

<p>&nbsp;</p>
Expand Down
Loading