Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit da2923d

Browse files
committed
LeetCode 付费题目描述 400~600
1 parent 5a338eb commit da2923d

File tree

68 files changed

+2908
-68
lines changed

Some content is hidden

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

68 files changed

+2908
-68
lines changed

‎solution/0400-0499/0408.Valid Word Abbreviation/README.md‎

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,35 @@
44

55
## 题目描述
66
<!-- 这里写题目描述 -->
7-
None
7+
<p>给一个 <strong>非空</strong> 字符串 <code>s</code> 和一个单词缩写 <code>abbr</code> ,判断这个缩写是否可以是给定单词的缩写。</p>
8+
9+
<p>字符串 <code>"word"</code> 的所有有效缩写为:</p>
10+
11+
<pre>["word", "1ord", "w1rd", "wo1d", "wor1", "2rd", "w2d", "wo2", "1o1d", "1or1", "w1r1", "1o2", "2r1", "3d", "w3", "4"]</pre>
12+
13+
<p>注意单词 <code>"word"</code> 的所有有效缩写仅包含以上这些。任何其他的字符串都不是 <code>"word"</code> 的有效缩写。</p>
14+
15+
<p><strong>注意:</strong><br>
16+
假设字符串 <code>s</code> 仅包含小写字母且 <code>abbr</code> 只包含小写字母和数字。</p>
17+
18+
<p><strong>示例 1:</strong></p>
19+
20+
<pre>给定 <strong>s</strong> = "internationalization", <strong>abbr</strong> = "i12iz4n":
21+
22+
函数返回 true.
23+
</pre>
24+
25+
<p> </p>
26+
27+
<p><strong>示例 2:</strong></p>
28+
29+
<pre>给定 <strong>s</strong> = "apple", <strong>abbr</strong> = "a2e":
30+
31+
函数返回 false.
32+
</pre>
33+
34+
<p> </p>
35+
836

937

1038
## 解法

‎solution/0400-0499/0408.Valid Word Abbreviation/README_EN.md‎

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,36 @@
33
[中文文档](/solution/0400-0499/0408.Valid%20Word%20Abbreviation/README.md)
44

55
## Description
6-
None
6+
<p>
7+
Given a <b>non-empty</b> string <code>s</code> and an abbreviation <code>abbr</code>, return whether the string matches with the given abbreviation.
8+
</p>
9+
10+
<p>A string such as <code>"word"</code> contains only the following valid abbreviations:</p>
11+
12+
<pre>["word", "1ord", "w1rd", "wo1d", "wor1", "2rd", "w2d", "wo2", "1o1d", "1or1", "w1r1", "1o2", "2r1", "3d", "w3", "4"]
13+
</pre>
14+
15+
<p>Notice that only the above abbreviations are valid abbreviations of the string <code>"word"</code>. Any other string is not a valid abbreviation of <code>"word"</code>.</p>
16+
17+
<p><b>Note:</b><br />
18+
Assume <code>s</code> contains only lowercase letters and <code>abbr</code> contains only lowercase letters and digits.
19+
</p>
20+
21+
<p><b>Example 1:</b><br />
22+
<pre>
23+
Given <b>s</b> = "internationalization", <b>abbr</b> = "i12iz4n":
24+
25+
Return true.
26+
</pre>
27+
</p>
28+
29+
<p><b>Example 2:</b><br />
30+
<pre>
31+
Given <b>s</b> = "apple", <b>abbr</b> = "a2e":
32+
33+
Return false.
34+
</pre>
35+
</p>
736

837

938
## Solutions

‎solution/0400-0499/0411.Minimum Unique Word Abbreviation/README.md‎

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,32 @@
44

55
## 题目描述
66
<!-- 这里写题目描述 -->
7-
None
7+
<p>字符串 <code>"word"</code> 包含以下这些缩写形式:</p>
8+
9+
<pre>["word", "1ord", "w1rd", "wo1d", "wor1", "2rd", "w2d", "wo2", "1o1d", "1or1", "w1r1", "1o2", "2r1", "3d", "w3", "4"]</pre>
10+
11+
<p>给一个目标字符串和一个字符串字典,为目标字符串找一个 <strong>最短 </strong>长度的缩写字符串,同时这个缩写字符串不是字典中其他字符串的缩写形式。</p>
12+
13+
<p>缩写形式中每一个 <strong>数字</strong> 或者字母都被视为长度为 1 。比方说,缩写形式 "a32bc" 的长度为 4 而不是 5 。</p>
14+
15+
<p><strong>注意:</strong></p>
16+
17+
<ul>
18+
<li>如果像第二个示例一样有多个有效答案,你可以返回它们中的任意一个。</li>
19+
<li>假设目标字符串的长度为 <strong>m </strong>,字典中的字符串数目为 <strong>n</strong> 。你可以假设 <strong>m ≤ 21</strong>, <strong>n ≤ 1000</strong>, 且 <strong>log<sub>2</sub>(n) + m ≤ 20</strong>.</li>
20+
</ul>
21+
22+
<p> </p>
23+
24+
<p><strong>示例:</strong></p>
25+
26+
<pre>"apple", ["blade"] -> "a4" (因为 "5" 或者 "4e" 同时也是 "blade" 的缩写形式,所以它们是无效的缩写)
27+
28+
"apple", ["plain", "amber", "blade"] -> "1p3" (其他有效的缩写形式还包括 "ap3", "a3e", "2p2", "3le", "3l1")。
29+
</pre>
30+
31+
<p> </p>
32+
833

934

1035
## 解法

‎solution/0400-0499/0411.Minimum Unique Word Abbreviation/README_EN.md‎

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,32 @@
33
[中文文档](/solution/0400-0499/0411.Minimum%20Unique%20Word%20Abbreviation/README.md)
44

55
## Description
6-
None
6+
<p>A string such as <code>"word"</code> contains the following abbreviations:</p>
7+
8+
<pre>
9+
["word", "1ord", "w1rd", "wo1d", "wor1", "2rd", "w2d", "wo2", "1o1d", "1or1", "w1r1", "1o2", "2r1", "3d", "w3", "4"]
10+
</pre>
11+
12+
<p>Given a target string and a set of strings in a dictionary, find an abbreviation of this target string with the <b><i>smallest possible</i></b> length such that it does not conflict with abbreviations of the strings in the dictionary.</p>
13+
14+
<p>Each <b>number</b> or letter in the abbreviation is considered length = 1. For example, the abbreviation "a32bc" has length = 4.</p>
15+
16+
<p><b>Examples:</b></p>
17+
18+
<pre>
19+
"apple", ["blade"] -> "a4" (because "5" or "4e" conflicts with "blade")
20+
21+
"apple", ["plain", "amber", "blade"] -> "1p3" (other valid answers include "ap3", "a3e", "2p2", "3le", "3l1").
22+
</pre>
23+
24+
<p> </p>
25+
<p><strong>Constraints:</strong></p>
26+
27+
<ul>
28+
<li>In the case of multiple answers as shown in the second example below, you may return any one of them.</li>
29+
<li>Assume length of target string = <b>m</b>, and dictionary size = <b>n</b>. You may assume that <b>m ≤ 21</b>, <b>n ≤ 1000</b>, and <b>log<sub>2</sub>(n) + m ≤ 20</b>.</li>
30+
</ul>
31+
732

833

934
## Solutions

‎solution/0400-0499/0418.Sentence Screen Fitting/README.md‎

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,75 @@
44

55
## 题目描述
66
<!-- 这里写题目描述 -->
7-
None
7+
<p>给你一个 <code>rows x cols</code> 的屏幕和一个用 <strong>非空 </strong>的单词列表组成的句子,请你计算出给定句子可以在屏幕上完整显示的次数。</p>
8+
9+
<p><strong>注意:</strong></p>
10+
11+
<ol>
12+
<li>一个单词不能拆分成两行。</li>
13+
<li>单词在句子中的顺序必须保持不变。</li>
14+
<li><strong>在一行中 </strong>的两个连续单词必须用一个空格符分隔。</li>
15+
<li>句子中的单词总量不会超过 100。</li>
16+
<li>每个单词的长度大于 0 且不会超过 10。</li>
17+
<li>1 ≤ <code>rows</code>, <code>cols</code> ≤ 20,000.</li>
18+
</ol>
19+
20+
<p> </p>
21+
22+
<p><strong>示例 1:</strong></p>
23+
24+
<pre><strong>输入:</strong>
25+
rows = 2, cols = 8, 句子 sentence = ["hello", "world"]
26+
27+
<strong>输出:</strong>
28+
1
29+
30+
<strong>解释:</strong>
31+
hello---
32+
world---
33+
34+
<strong>字符 '-' 表示屏幕上的一个空白位置。</strong>
35+
</pre>
36+
37+
<p> </p>
38+
39+
<p><strong>示例 2:</strong></p>
40+
41+
<pre><strong>输入:</strong>
42+
rows = 3, cols = 6, 句子 sentence = ["a", "bcd", "e"]
43+
44+
<strong>输出:</strong>
45+
2
46+
47+
<strong>解释:</strong>
48+
a-bcd-
49+
e-a---
50+
bcd-e-
51+
52+
<strong>字符 '-' 表示屏幕上的一个空白位置。</strong>
53+
</pre>
54+
55+
<p> </p>
56+
57+
<p><strong>示例 3:</strong></p>
58+
59+
<pre><strong>输入:</strong>
60+
rows = 4, cols = 5, 句子 sentence = ["I", "had", "apple", "pie"]
61+
62+
<strong>输出:</strong>
63+
1
64+
65+
<strong>解释:</strong>
66+
I-had
67+
apple
68+
pie-I
69+
had--
70+
71+
<strong>字符 '-' 表示屏幕上的一个空白位置。</strong>
72+
</pre>
73+
74+
<p> </p>
75+
876

977

1078
## 解法

‎solution/0400-0499/0418.Sentence Screen Fitting/README_EN.md‎

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,73 @@
33
[中文文档](/solution/0400-0499/0418.Sentence%20Screen%20Fitting/README.md)
44

55
## Description
6-
None
6+
<p>Given a <code>rows x cols</code> screen and a sentence represented by a list of <b>non-empty</b> words, find <b>how many times</b> the given sentence can be fitted on the screen.
7+
</p>
8+
9+
<p><b>Note:</b>
10+
<ol>
11+
<li>A word cannot be split into two lines.</li>
12+
<li>The order of words in the sentence must remain unchanged.</li>
13+
<li>Two consecutive words <b>in a line</b> must be separated by a single space.</li>
14+
<li>Total words in the sentence won't exceed 100.</li>
15+
<li>Length of each word is greater than 0 and won't exceed 10.</li>
16+
<li>1 ≤ rows, cols ≤ 20,000.</li>
17+
</ol>
18+
</p>
19+
20+
<p>
21+
<b>Example 1:</b>
22+
<pre>
23+
<b>Input:</b>
24+
rows = 2, cols = 8, sentence = ["hello", "world"]
25+
26+
<b>Output:</b>
27+
1
28+
29+
<b>Explanation:</b>
30+
hello---
31+
world---
32+
33+
The character '-' signifies an empty space on the screen.
34+
</pre>
35+
</p>
36+
37+
<p>
38+
<b>Example 2:</b>
39+
<pre>
40+
<b>Input:</b>
41+
rows = 3, cols = 6, sentence = ["a", "bcd", "e"]
42+
43+
<b>Output:</b>
44+
2
45+
46+
<b>Explanation:</b>
47+
a-bcd-
48+
e-a---
49+
bcd-e-
50+
51+
The character '-' signifies an empty space on the screen.
52+
</pre>
53+
</p>
54+
55+
<p>
56+
<b>Example 3:</b>
57+
<pre>
58+
<b>Input:</b>
59+
rows = 4, cols = 5, sentence = ["I", "had", "apple", "pie"]
60+
61+
<b>Output:</b>
62+
1
63+
64+
<b>Explanation:</b>
65+
I-had
66+
apple
67+
pie-I
68+
had--
69+
70+
The character '-' signifies an empty space on the screen.
71+
</pre>
72+
</p>
773

874

975
## Solutions

‎solution/0400-0499/0422.Valid Word Square/README.md‎

Lines changed: 83 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,89 @@
44

55
## 题目描述
66
<!-- 这里写题目描述 -->
7-
None
7+
<p>给你一个单词序列,判断其是否形成了一个有效的单词方块。</p>
8+
9+
<p>有效的单词方块是指此由单词序列组成的文字方块的 第 k 行 和 第 k 列 (0 ≤ <em>k</em> < max(行数, 列数)) 所显示的字符串完全相同。</p>
10+
11+
<p><strong>注意:</strong></p>
12+
13+
<ol>
14+
<li>给定的单词数大于等于 1 且不超过 500。</li>
15+
<li>单词长度大于等于 1 且不超过 500。</li>
16+
<li>每个单词只包含小写英文字母 <code>a-z</code>。</li>
17+
</ol>
18+
19+
<p> </p>
20+
21+
<p><strong>示例 1:</strong></p>
22+
23+
<pre><strong>输入:</strong>
24+
[
25+
"abcd",
26+
"bnrt",
27+
"crmy",
28+
"dtye"
29+
]
30+
31+
<strong>输出:</strong>
32+
true
33+
34+
<strong>解释:</strong>
35+
第 1 行和第 1 列都是 "abcd"。
36+
第 2 行和第 2 列都是 "bnrt"。
37+
第 3 行和第 3 列都是 "crmy"。
38+
第 4 行和第 4 列都是 "dtye"。
39+
40+
因此,这是一个有效的单词方块。
41+
</pre>
42+
43+
<p> </p>
44+
45+
<p><strong>示例 2:</strong></p>
46+
47+
<pre><strong>输入:</strong>
48+
[
49+
"abcd",
50+
"bnrt",
51+
"crm",
52+
"dt"
53+
]
54+
55+
<strong>输出:</strong>
56+
true
57+
58+
<strong>解释:</strong>
59+
第 1 行和第 1 列都是 "abcd"。
60+
第 2 行和第 2 列都是 "bnrt"。
61+
第 3 行和第 3 列都是 "crm"。
62+
第 4 行和第 4 列都是 "dt"。
63+
64+
因此,这是一个有效的单词方块。
65+
</pre>
66+
67+
<p> </p>
68+
69+
<p><strong>示例 3:</strong></p>
70+
71+
<pre><strong>输入:</strong>
72+
[
73+
"ball",
74+
"area",
75+
"read",
76+
"lady"
77+
]
78+
79+
<strong>输出:</strong>
80+
false
81+
82+
<strong>解释:</strong>
83+
第 3 行是 "read" ,然而第 3 列是 "lead"。
84+
85+
因此,这 <strong>不是</strong> 一个有效的单词方块。
86+
</pre>
87+
88+
<p> </p>
89+
890

991

1092
## 解法

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /