Skip to content

Commit 48eaf39

Browse files
committed
update
1 parent 947eefe commit 48eaf39

File tree

83 files changed

+21090
-12870
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+21090
-12870
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# 力扣题库(完整版)
22

3-
> 最后更新日期: **2023.02.11**
3+
> 最后更新日期: **2023.02.27**
44
>
55
> 使用脚本前请务必仔细完整阅读本 `README.md` 文件
66

leetcode-cn/origin-data.json

+8,051-7,715
Large diffs are not rendered by default.

leetcode-cn/originData/count-the-number-of-fair-pairs.json

+190
Large diffs are not rendered by default.

leetcode-cn/originData/count-the-number-of-square-free-subsets.json

+165
Large diffs are not rendered by default.

leetcode-cn/originData/find-the-array-concatenation-value.json

+184
Large diffs are not rendered by default.

leetcode-cn/originData/find-the-divisibility-array-of-a-string.json

+164
Large diffs are not rendered by default.

leetcode-cn/originData/find-the-maximum-number-of-marked-indices.json

+166
Large diffs are not rendered by default.

leetcode-cn/originData/find-the-string-with-lcp.json

+165
Large diffs are not rendered by default.

leetcode-cn/originData/handling-sum-queries-after-update.json

+163
Large diffs are not rendered by default.

leetcode-cn/originData/left-and-right-sum-differences.json

+164
Large diffs are not rendered by default.

leetcode-cn/originData/maximum-difference-by-remapping-a-digit.json

+164
Large diffs are not rendered by default.

leetcode-cn/originData/merge-two-2d-arrays-by-summing-values.json

+163
Large diffs are not rendered by default.

leetcode-cn/originData/minimum-impossible-or.json

+164
Large diffs are not rendered by default.

leetcode-cn/originData/minimum-operations-to-reduce-an-integer-to-0.json

+165
Large diffs are not rendered by default.

leetcode-cn/originData/minimum-score-by-changing-two-elements.json

+164
Large diffs are not rendered by default.

leetcode-cn/originData/minimum-time-to-visit-a-cell-in-a-grid.json

+164
Large diffs are not rendered by default.

leetcode-cn/originData/subsequence-with-the-minimum-score.json

+184
Large diffs are not rendered by default.

leetcode-cn/originData/substring-xor-queries.json

+189
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<p>给你一个下标从 <strong>0</strong>&nbsp;开始的整数数组&nbsp;<code>nums</code>&nbsp;。</p>
2+
3+
<ul>
4+
<li><code>nums</code><strong>最小</strong>&nbsp;得分是满足 <code>0 &lt;= i &lt; j &lt; nums.length</code>&nbsp;的&nbsp;<code>|nums[i]&nbsp;- nums[j]|</code>&nbsp;的最小值。</li>
5+
<li><code>nums</code><strong>最大 </strong>得分是满足 <code>0 &lt;= i &lt; j &lt; nums.length</code>&nbsp;的&nbsp;<code>|nums[i]&nbsp;- nums[j]|</code>&nbsp;的最大值。</li>
6+
<li><code>nums</code>&nbsp;的分数是 <strong>最大</strong>&nbsp;得分与 <strong>最小</strong>&nbsp;得分的和。</li>
7+
</ul>
8+
9+
<p>我们的目标是最小化&nbsp;<code>nums</code>&nbsp;的分数。你 <strong>最多</strong> 可以修改&nbsp;<code>nums</code>&nbsp;中&nbsp;<strong>2</strong>&nbsp;个元素的值。</p>
10+
11+
<p>请你返回修改&nbsp;<code>nums</code>&nbsp;中&nbsp;<strong>至多两个</strong>&nbsp;元素的值后,可以得到的 <strong>最小分数</strong>&nbsp;。</p>
12+
13+
<p><code>|x|</code>&nbsp;表示 <code>x</code>&nbsp;的绝对值。</p>
14+
15+
<p>&nbsp;</p>
16+
17+
<p><strong>示例 1:</strong></p>
18+
19+
<pre>
20+
<b>输入:</b>nums = [1,4,3]
21+
<b>输出:</b>0
22+
<b>解释:</b>将 nums[1] 和 nums[2] 的值改为 1 ,nums 变为 [1,1,1] 。<code>|nums[i] - nums[j]|</code> 的值永远为 0 ,所以我们返回 0 + 0 = 0 。
23+
</pre>
24+
25+
<p><strong>示例 2:</strong></p>
26+
27+
<pre>
28+
<b>输入:</b>nums = [1,4,7,8,5]
29+
<b>输出:</b>3
30+
<b>解释:
31+
</b>将 nums[0] 和 nums[1] 的值变为 6 ,nums 变为 [6,6,7,8,5] 。
32+
最小得分是 i = 0 且 j = 1 时得到的 |<code>nums[i] - nums[j]</code>| = |6 - 6| = 0 。
33+
最大得分是 i = 3 且 j = 4 时得到的 |<code>nums[i] - nums[j]</code>| = |8 - 5| = 3 。
34+
最大得分与最小得分之和为 3 。这是最优答案。
35+
</pre>
36+
37+
<p>&nbsp;</p>
38+
39+
<p><strong>提示:</strong></p>
40+
41+
<ul>
42+
<li><code>3 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
43+
<li><code>1 &lt;= nums[i] &lt;= 10<sup>9</sup></code></li>
44+
</ul>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<p>给你两个 <strong>二维</strong> 整数数组 <code>nums1</code><code>nums2.</code></p>
2+
3+
<ul>
4+
<li><code>nums1[i] = [id<sub>i</sub>, val<sub>i</sub>]</code> 表示编号为 <code>id<sub>i</sub></code> 的数字对应的值等于 <code>val<sub>i</sub></code></li>
5+
<li><code>nums2[i] = [id<sub>i</sub>, val<sub>i</sub>]</code>&nbsp;表示编号为 <code>id<sub>i</sub></code> 的数字对应的值等于 <code>val<sub>i</sub></code></li>
6+
</ul>
7+
8+
<p>每个数组都包含 <strong>互不相同</strong> 的 id ,并按 id 以 <strong>递增</strong> 顺序排列。</p>
9+
10+
<p>请你将两个数组合并为一个按 id 以递增顺序排列的数组,并符合下述条件:</p>
11+
12+
<ul>
13+
<li>只有在两个数组中至少出现过一次的 id 才能包含在结果数组内。</li>
14+
<li>每个 id 在结果数组中 <strong>只能出现一次</strong> ,并且其对应的值等于两个数组中该 id 所对应的值求和。如果某个数组中不存在该 id ,则认为其对应的值等于 <code>0</code></li>
15+
</ul>
16+
17+
<p>返回结果数组。返回的数组需要按 id 以递增顺序排列。</p>
18+
19+
<p>&nbsp;</p>
20+
21+
<p><strong>示例 1:</strong></p>
22+
23+
<pre><strong>输入:</strong>nums1 = [[1,2],[2,3],[4,5]], nums2 = [[1,4],[3,2],[4,1]]
24+
<strong>输出:</strong>[[1,6],[2,3],[3,2],[4,6]]
25+
<strong>解释:</strong>结果数组中包含以下元素:
26+
- id = 1 ,对应的值等于 2 + 4 = 6 。
27+
- id = 2 ,对应的值等于 3 。
28+
- id = 3 ,对应的值等于 2 。
29+
- id = 4 ,对应的值等于5 + 1 = 6 。
30+
</pre>
31+
32+
<p><strong>示例 2:</strong></p>
33+
34+
<pre><strong>输入:</strong>nums1 = [[2,4],[3,6],[5,5]], nums2 = [[1,3],[4,3]]
35+
<strong>输出:</strong>[[1,3],[2,4],[3,6],[4,3],[5,5]]
36+
<strong>解释:</strong>不存在共同 id ,在结果数组中只需要包含每个 id 和其对应的值。
37+
</pre>
38+
39+
<p>&nbsp;</p>
40+
41+
<p><strong>提示:</strong></p>
42+
43+
<ul>
44+
<li><code>1 &lt;= nums1.length, nums2.length &lt;= 200</code></li>
45+
<li><code>nums1[i].length == nums2[j].length == 2</code></li>
46+
<li><code>1 &lt;= id<sub>i</sub>, val<sub>i</sub> &lt;= 1000</code></li>
47+
<li>数组中的 id 互不相同</li>
48+
<li>数据均按 id 以严格递增顺序排列</li>
49+
</ul>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<p>给你一个&nbsp;<code>m x n</code>&nbsp;的矩阵&nbsp;<code>grid</code>&nbsp;,每个元素都为 <strong>非负</strong>&nbsp;整数,其中&nbsp;<code>grid[row][col]</code>&nbsp;表示可以访问格子&nbsp;<code>(row, col)</code>&nbsp;的&nbsp;<strong>最早</strong>&nbsp;时间。也就是说当你访问格子&nbsp;<code>(row, col)</code>&nbsp;时,最少已经经过的时间为&nbsp;<code>grid[row][col]</code>&nbsp;。</p>
2+
3+
<p>你从 <strong>最左上角</strong>&nbsp;出发,出发时刻为 <code>0</code>&nbsp;,你必须一直移动到上下左右相邻四个格子中的 <strong>任意</strong>&nbsp;一个格子(即不能停留在格子上)。每次移动都需要花费 1 单位时间。</p>
4+
5+
<p>请你返回 <strong>最早</strong>&nbsp;到达右下角格子的时间,如果你无法到达右下角的格子,请你返回 <code>-1</code>&nbsp;。</p>
6+
7+
<p>&nbsp;</p>
8+
9+
<p><strong>示例 1:</strong></p>
10+
11+
<p><img alt="" src="https://assets.leetcode.com/uploads/2023/02/14/yetgriddrawio-8.png" /></p>
12+
13+
<pre>
14+
<b>输入:</b>grid = [[0,1,3,2],[5,1,2,5],[4,3,8,6]]
15+
<b>输出:</b>7
16+
<b>解释:</b>一条可行的路径为:
17+
- 时刻 t = 0 ,我们在格子 (0,0) 。
18+
- 时刻 t = 1 ,我们移动到格子 (0,1) ,可以移动的原因是 grid[0][1] &lt;= 1 。
19+
- 时刻 t = 2 ,我们移动到格子 (1,1) ,可以移动的原因是 grid[1][1] &lt;= 2 。
20+
- 时刻 t = 3 ,我们移动到格子 (1,2) ,可以移动的原因是 grid[1][2] &lt;= 3 。
21+
- 时刻 t = 4 ,我们移动到格子 (1,1) ,可以移动的原因是 grid[1][1] &lt;= 4 。
22+
- 时刻 t = 5 ,我们移动到格子 (1,2) ,可以移动的原因是 grid[1][2] &lt;= 5 。
23+
- 时刻 t = 6 ,我们移动到格子 (1,3) ,可以移动的原因是 grid[1][3] &lt;= 6 。
24+
- 时刻 t = 7 ,我们移动到格子 (2,3) ,可以移动的原因是 grid[2][3] &lt;= 7 。
25+
最终到达时刻为 7 。这是最早可以到达的时间。
26+
</pre>
27+
28+
<p><strong>示例 2:</strong></p>
29+
30+
<p><img alt="" src="https://assets.leetcode.com/uploads/2023/02/14/yetgriddrawio-9.png" style="width: 151px; height: 151px;" /></p>
31+
32+
<pre>
33+
<b>输入:</b>grid = [[0,2,4],[3,2,1],[1,0,4]]
34+
<b>输出:</b>-1
35+
<b>解释:</b>没法从左上角按题目规定走到右下角。
36+
</pre>
37+
38+
<p>&nbsp;</p>
39+
40+
<p><strong>提示:</strong></p>
41+
42+
<ul>
43+
<li><code>m == grid.length</code></li>
44+
<li><code>n == grid[i].length</code></li>
45+
<li><code>2 &lt;= m, n &lt;= 1000</code></li>
46+
<li><code>4 &lt;= m * n &lt;= 10<sup>5</sup></code></li>
47+
<li><code>0 &lt;= grid[i][j] &lt;= 10<sup>5</sup></code></li>
48+
<li><code>grid[0][0] == 0</code></li>
49+
</ul>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<p>给你一个 <strong>二进制字符串</strong>&nbsp;<code>s</code>&nbsp;和一个整数数组&nbsp;<code>queries</code>&nbsp;,其中&nbsp;<code>queries[i] = [first<sub>i</sub>, second<sub>i</sub>]</code>&nbsp;。</p>
2+
3+
<p>对于第&nbsp;<code>i</code>&nbsp;个查询,找到 <code>s</code>&nbsp;的 <strong>最短子字符串</strong>&nbsp;,它对应的 <strong>十进制</strong>值&nbsp;<code>val</code>&nbsp;与&nbsp;<code>first<sub>i</sub></code>&nbsp;<b>按位异或</b>&nbsp;得到&nbsp;<code>second<sub>i</sub></code>&nbsp;,换言之,<code>val ^ first<sub>i</sub> == second<sub>i</sub></code>&nbsp;。</p>
4+
5+
<p>第&nbsp;<code>i</code>&nbsp;个查询的答案是子字符串&nbsp;<code>[left<sub>i</sub>, right<sub>i</sub>]</code> 的两个端点(下标从&nbsp;<strong>0</strong>&nbsp;开始),如果不存在这样的子字符串,则答案为&nbsp;<code>[-1, -1]</code>&nbsp;。如果有多个答案,请你选择&nbsp;<code>left<sub>i</sub></code>&nbsp;最小的一个。</p>
6+
7+
<p>请你返回一个数组&nbsp;<code>ans</code>&nbsp;,其中&nbsp;<code>ans[i] = [left<sub>i</sub>, right<sub>i</sub>]</code>&nbsp;是第&nbsp;<code>i</code>&nbsp;个查询的答案。</p>
8+
9+
<p><strong>子字符串</strong>&nbsp;是一个字符串中一段连续非空的字符序列。</p>
10+
11+
<p>&nbsp;</p>
12+
13+
<p><strong>示例 1:</strong></p>
14+
15+
<pre>
16+
<b>输入:</b>s = "101101", queries = [[0,5],[1,2]]
17+
<b>输出:</b>[[0,2],[2,3]]
18+
<b>解释:</b>第一个查询,端点为 <code>[0,2]</code> 的子字符串为 <strong>"101"</strong> ,对应十进制数字 <strong><code>5 ,且</code></strong> <strong><code>5 ^ 0 = 5</code></strong>&nbsp;,所以第一个查询的答案为 <code>[0,2]。第二个查询中,</code>端点为 <code>[2,3] 的子字符串为 </code><strong>"11" ,对应十进制数字</strong> <strong>3</strong>&nbsp;,且 <strong>3<code> ^ 1 = 2</code></strong><code>&nbsp;。所以第二个查询的答案为</code> <code>[2,3]</code>
19+
</pre>
20+
21+
<p><strong>示例 2:</strong></p>
22+
23+
<pre>
24+
<b>输入:</b>s = "0101", queries = [[12,8]]
25+
<b>输出:</b>[[-1,-1]]
26+
<b>解释:</b>这个例子中,没有符合查询的答案,所以返回 <code>[-1,-1] 。</code>
27+
</pre>
28+
29+
<p><strong>示例 3:</strong></p>
30+
31+
<pre>
32+
<b>输入:</b>s = "1", queries = [[4,5]]
33+
<b>输出:</b>[[0,0]]
34+
<b>解释:</b>这个例子中,端点为 <code>[0,0]</code> 的子字符串对应的十进制值为 <strong><code>1</code></strong><code>&nbsp;,且</code> <strong><code>1 ^ 4 = 5</code></strong><code>&nbsp;。所以答案为</code> <code>[0,0] 。</code>
35+
</pre>
36+
37+
<p>&nbsp;</p>
38+
39+
<p><strong>提示:</strong></p>
40+
41+
<ul>
42+
<li><code>1 &lt;= s.length &lt;= 10<sup>4</sup></code></li>
43+
<li><code>s[i]</code>&nbsp;要么是&nbsp;<code>'0'</code>&nbsp;,要么是&nbsp;<code>'1'</code>&nbsp;。</li>
44+
<li><code>1 &lt;= queries.length &lt;= 10<sup>5</sup></code></li>
45+
<li><code>0 &lt;= first<sub>i</sub>, second<sub>i</sub> &lt;= 10<sup>9</sup></code></li>
46+
</ul>
47+
48+
<p>&nbsp;</p>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<p>给你一个正整数 <code>n</code> ,你可以执行下述操作 <strong>任意</strong> 次:</p>
2+
3+
<ul>
4+
<li><code>n</code> 加上或减去 <code>2</code> 的某个 <strong></strong></li>
5+
</ul>
6+
7+
<p>返回使 <code>n</code> 等于 <code>0</code> 需要执行的 <strong>最少</strong> 操作数。</p>
8+
9+
<p>如果 <code>x == 2<sup>i</sup></code> 且其中 <code>i &gt;= 0</code> ,则数字 <code>x</code><code>2</code> 的幂。</p>
10+
11+
<p>&nbsp;</p>
12+
13+
<p><strong>示例 1:</strong></p>
14+
15+
<pre>
16+
<strong>输入:</strong>n = 39
17+
<strong>输出:</strong>3
18+
<strong>解释:</strong>我们可以执行下述操作:
19+
- n 加上 2<sup>0</sup> = 1 ,得到 n = 40 。
20+
- n 减去 2<sup>3</sup> = 8 ,得到 n = 32 。
21+
- n 减去 2<sup>5</sup> = 32 ,得到 n = 0 。
22+
可以证明使 n 等于 0 需要执行的最少操作数是 3 。
23+
</pre>
24+
25+
<p><strong>示例 2:</strong></p>
26+
27+
<pre>
28+
<strong>输入:</strong>n = 54
29+
<strong>输出:</strong>3
30+
<strong>解释:</strong>我们可以执行下述操作:
31+
- n 加上 2<sup>1</sup> = 2 ,得到 n = 56 。
32+
- n 加上 2<sup>3</sup> = 8 ,得到 n = 64 。
33+
- n 减去 2<sup>6</sup> = 64 ,得到 n = 0 。
34+
使 n 等于 0 需要执行的最少操作数是 3 。
35+
</pre>
36+
37+
<p>&nbsp;</p>
38+
39+
<p><strong>提示:</strong></p>
40+
41+
<ul>
42+
<li><code>1 &lt;= n &lt;= 10<sup>5</sup></code></li>
43+
</ul>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<p>给你一个下标从 <strong>0</strong> 开始的整数数组 <code>nums</code> ,请你找出一个下标从 <strong>0</strong> 开始的整数数组 <code>answer</code> ,其中:</p>
2+
3+
<ul>
4+
<li><code>answer.length == nums.length</code></li>
5+
<li><code>answer[i] = |leftSum[i] - rightSum[i]|</code></li>
6+
</ul>
7+
8+
<p>其中:</p>
9+
10+
<ul>
11+
<li><code>leftSum[i]</code> 是数组 <code>nums</code> 中下标 <code>i</code> 左侧元素之和。如果不存在对应的元素,<code>leftSum[i] = 0</code></li>
12+
<li><code>rightSum[i]</code> 是数组 <code>nums</code> 中下标 <code>i</code> 右侧元素之和。如果不存在对应的元素,<code>rightSum[i] = 0</code></li>
13+
</ul>
14+
15+
<p>返回数组 <code>answer</code></p>
16+
17+
<p>&nbsp;</p>
18+
19+
<p><strong>示例 1:</strong></p>
20+
21+
<pre><strong>输入:</strong>nums = [10,4,8,3]
22+
<strong>输出:</strong>[15,1,11,22]
23+
<strong>解释:</strong>数组 leftSum 为 [0,10,14,22] 且数组 rightSum 为 [15,11,3,0] 。
24+
数组 answer 为 [|0 - 15|,|10 - 11|,|14 - 3|,|22 - 0|] = [15,1,11,22] 。
25+
</pre>
26+
27+
<p><strong>示例 2:</strong></p>
28+
29+
<pre><strong>输入:</strong>nums = [1]
30+
<strong>输出:</strong>[0]
31+
<strong>解释:</strong>数组 leftSum 为 [0] 且数组 rightSum 为 [0] 。
32+
数组 answer 为 [|0 - 0|] = [0] 。
33+
</pre>
34+
35+
<p>&nbsp;</p>
36+
37+
<p><strong>提示:</strong></p>
38+
39+
<ul>
40+
<li><code>1 &lt;= nums.length &lt;= 1000</code></li>
41+
<li><code>1 &lt;= nums[i] &lt;= 10<sup>5</sup></code></li>
42+
</ul>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<p>给你一个下标从 <strong>0</strong> 开始的字符串 <code>word</code> ,长度为 <code>n</code> ,由从 <code>0</code><code>9</code> 的数字组成。另给你一个正整数 <code>m</code></p>
2+
3+
<p><code>word</code><strong>可整除数组</strong> <code>div</code>&nbsp; 是一个长度为 <code>n</code> 的整数数组,并满足:</p>
4+
5+
<ul>
6+
<li>如果 <code>word[0,...,i]</code> 所表示的 <strong>数值</strong> 能被 <code>m</code> 整除,<code>div[i] = 1</code></li>
7+
<li>否则,<code>div[i] = 0</code></li>
8+
</ul>
9+
10+
<p>返回<em> </em><code>word</code> 的可整除数组。</p>
11+
12+
<p>&nbsp;</p>
13+
14+
<p><strong>示例 1:</strong></p>
15+
16+
<pre>
17+
<strong>输入:</strong>word = "998244353", m = 3
18+
<strong>输出:</strong>[1,1,0,0,0,1,1,0,0]
19+
<strong>解释:</strong>仅有 4 个前缀可以被 3 整除:"9"、"99"、"998244" 和 "9982443" 。
20+
</pre>
21+
22+
<p><strong>示例 2:</strong></p>
23+
24+
<pre>
25+
<strong>输入:</strong>word = "1010", m = 10
26+
<strong>输出:</strong>[0,1,0,1]
27+
<strong>解释:</strong>仅有 2 个前缀可以被 10 整除:"10" 和 "1010" 。
28+
</pre>
29+
30+
<p>&nbsp;</p>
31+
32+
<p><strong>提示:</strong></p>
33+
34+
<ul>
35+
<li><code>1 &lt;= n &lt;= 10<sup>5</sup></code></li>
36+
<li><code>word.length == n</code></li>
37+
<li><code>word</code> 由数字 <code>0</code><code>9</code> 组成</li>
38+
<li><code>1 &lt;= m &lt;= 10<sup>9</sup></code></li>
39+
</ul>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<p>对任一由 <code>n</code> 个小写英文字母组成的字符串 <code>word</code> ,我们可以定义一个 <code>n x n</code> 的矩阵,并满足:</p>
2+
3+
<ul>
4+
<li><code>lcp[i][j]</code> 等于子字符串&nbsp;<code>word[i,...,n-1]</code><code>word[j,...,n-1]</code> 之间的最长公共前缀的长度。</li>
5+
</ul>
6+
7+
<p>给你一个 <code>n x n</code> 的矩阵 <code>lcp</code> 。返回与 <code>lcp</code> 对应的、按字典序最小的字符串&nbsp;<code>word</code> 。如果不存在这样的字符串,则返回空字符串。</p>
8+
9+
<p>对于长度相同的两个字符串 <code>a</code><code>b</code> ,如果在 <code>a</code><code>b</code> 不同的第一个位置,字符串 <code>a</code> 的字母在字母表中出现的顺序先于 <code>b</code> 中的对应字母,则认为字符串 <code>a</code> 按字典序比字符串 <code>b</code> 小。例如,<code>"aabd"</code> 在字典上小于 <code>"aaca"</code> ,因为二者不同的第一位置是第三个字母,而&nbsp;<code>'b'</code> 先于 <code>'c'</code> 出现。</p>
10+
11+
<p>&nbsp;</p>
12+
13+
<p><strong>示例 1:</strong></p>
14+
15+
<pre>
16+
<strong>输入:</strong>lcp = [[4,0,2,0],[0,3,0,1],[2,0,2,0],[0,1,0,1]]
17+
<strong>输出:</strong>"abab"
18+
<strong>解释:</strong>lcp 对应由两个交替字母组成的任意 4 字母字符串,字典序最小的是 "abab" 。
19+
</pre>
20+
21+
<p><strong>示例 2:</strong></p>
22+
23+
<pre>
24+
<strong>输入:</strong>lcp = [[4,3,2,1],[3,3,2,1],[2,2,2,1],[1,1,1,1]]
25+
<strong>输出:</strong>"aaaa"
26+
<strong>解释:</strong>lcp 对应只有一个不同字母的任意 4 字母字符串,字典序最小的是 "aaaa" 。
27+
</pre>
28+
29+
<p><strong>示例 3:</strong></p>
30+
31+
<pre>
32+
<strong>输入:</strong>lcp = [[4,3,2,1],[3,3,2,1],[2,2,2,1],[1,1,1,3]]
33+
<strong>输出:</strong>""
34+
<strong>解释:</strong>lcp[3][3] 无法等于 3 ,因为 word[3,...,3] 仅由单个字母组成;因此,不存在答案。
35+
</pre>
36+
37+
<p>&nbsp;</p>
38+
39+
<p><strong>提示:</strong></p>
40+
41+
<ul>
42+
<li><code>1 &lt;= n ==&nbsp;</code><code>lcp.length == </code><code>lcp[i].length</code>&nbsp;<code>&lt;= 1000</code></li>
43+
<li><code><font face="monospace">0 &lt;= lcp[i][j] &lt;= n</font></code></li>
44+
</ul>

0 commit comments

Comments
 (0)