Skip to content

Commit 98df9c5

Browse files
committed
LeetCode 付费题目描述 600~1000
1 parent da2923d commit 98df9c5

File tree

72 files changed

+2749
-72
lines changed

Some content is hidden

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

72 files changed

+2749
-72
lines changed

solution/0600-0699/0604.Design Compressed String Iterator/README.md

+30-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,36 @@
44

55
## 题目描述
66
<!-- 这里写题目描述 -->
7-
None
7+
<p>对于一个压缩字符串,设计一个数据结构,它支持如下两种操作: <code>next</code> 和 <code>hasNext</code>。</p>
8+
9+
<p>给定的压缩字符串格式为:每个字母后面紧跟一个正整数,这个整数表示该字母在解压后的字符串里连续出现的次数。</p>
10+
11+
<p><code>next()</code> - 如果压缩字符串仍然有字母未被解压,则返回下一个字母,否则返回一个空格。<br>
12+
<code>hasNext()</code> - 判断是否还有字母仍然没被解压。</p>
13+
14+
<p><strong>注意:</strong></p>
15+
16+
<p>请记得将你的类在 StringIterator 中 <strong>初始化</strong> ,因为静态变量或类变量在多组测试数据中不会被自动清空。更多细节请访问 <a href="http://leetcode.com/faq/#different-output">这里</a> 。</p>
17+
18+
<p><strong>示例:</strong></p>
19+
20+
<pre>StringIterator iterator = new StringIterator("L1e2t1C1o1d1e1");
21+
22+
iterator.next(); // 返回 'L'
23+
iterator.next(); // 返回 'e'
24+
iterator.next(); // 返回 'e'
25+
iterator.next(); // 返回 't'
26+
iterator.next(); // 返回 'C'
27+
iterator.next(); // 返回 'o'
28+
iterator.next(); // 返回 'd'
29+
iterator.hasNext(); // 返回 true
30+
iterator.next(); // 返回 'e'
31+
iterator.hasNext(); // 返回 false
32+
iterator.next(); // 返回 ' '
33+
</pre>
34+
35+
<p> </p>
36+
837

938

1039
## 解法

solution/0600-0699/0604.Design Compressed String Iterator/README_EN.md

+42-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,48 @@
33
[中文文档](/solution/0600-0699/0604.Design%20Compressed%20String%20Iterator/README.md)
44

55
## Description
6-
None
6+
<p>Design and implement a data structure for a compressed string iterator. The given compressed string will be in the form of each letter followed by a positive integer representing the number of this letter existing in the original uncompressed string.</p>
7+
8+
<p>Implement the StringIterator class:</p>
9+
10+
<ul>
11+
<li><code>next()</code> Returns <strong>the next character</strong> if the original string still has uncompressed characters, otherwise returns a <strong>white space</strong>.</li>
12+
<li><code>hasNext()</code> Returns true if there is any letter needs to be uncompressed in the original string, otherwise returns <code>false</code>.</li>
13+
</ul>
14+
15+
<p> </p>
16+
<p><strong>Example 1:</strong></p>
17+
18+
<pre>
19+
<strong>Input</strong>
20+
["StringIterator", "next", "next", "next", "next", "next", "next", "hasNext", "next", "hasNext"]
21+
[["L1e2t1C1o1d1e1"], [], [], [], [], [], [], [], [], []]
22+
<strong>Output</strong>
23+
[null, "L", "e", "e", "t", "C", "o", true, "d", true]
24+
25+
<strong>Explanation</strong>
26+
StringIterator stringIterator = new StringIterator("L1e2t1C1o1d1e1");
27+
stringIterator.next(); // return "L"
28+
stringIterator.next(); // return "e"
29+
stringIterator.next(); // return "e"
30+
stringIterator.next(); // return "t"
31+
stringIterator.next(); // return "C"
32+
stringIterator.next(); // return "o"
33+
stringIterator.hasNext(); // return True
34+
stringIterator.next(); // return "d"
35+
stringIterator.hasNext(); // return True
36+
</pre>
37+
38+
<p> </p>
39+
<p><strong>Constraints:</strong></p>
40+
41+
<ul>
42+
<li><code>1 <= compressedString.length <= 1000</code></li>
43+
<li><code>compressedString</code> consists of lower-case an upper-case English letters and digits.</li>
44+
<li>The number of a single character repetitions in <code>compressedString</code> is in the range <code>[1, 10^9]</code></li>
45+
<li>At most <code>100</code> calls will be made to <code>next</code> and <code>hasNext</code>.</li>
46+
</ul>
47+
748

849

950
## Solutions

solution/0600-0699/0616.Add Bold Tag in String/README.md

+33-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,39 @@
44

55
## 题目描述
66
<!-- 这里写题目描述 -->
7-
None
7+
<p>给一个字符串 <strong>s</strong> 和一个字符串列表 <strong>dict</strong> ,你需要将在字符串列表中出现过的 s 的子串添加加粗闭合标签 <code><b></code> 和 <code></b></code> 。如果两个子串有重叠部分,你需要把它们一起用一个闭合标签包围起来。同理,如果两个子字符串连续被加粗,那么你也需要把它们合起来用一个加粗标签包围。</p>
8+
9+
<p><strong>样例 1:</strong></p>
10+
11+
<pre><strong>输入:</strong>
12+
s = "abcxyz123"
13+
dict = ["abc","123"]
14+
<strong>输出:</strong>
15+
"<b>abc</b>xyz<b>123</b>"
16+
</pre>
17+
18+
<p> </p>
19+
20+
<p><strong>样例 2:</strong></p>
21+
22+
<pre><strong>输入:</strong>
23+
s = "aaabbcc"
24+
dict = ["aaa","aab","bc"]
25+
<strong>输出:</strong>
26+
"<b>aaabbc</b>c"
27+
</pre>
28+
29+
<p> </p>
30+
31+
<p><strong>注意:</strong></p>
32+
33+
<ol>
34+
<li>给定的 dict 中不会有重复的字符串,且字符串数目不会超过 100 。</li>
35+
<li>输入中的所有字符串长度都在范围 [1, 1000] 内。</li>
36+
</ol>
37+
38+
<p> </p>
39+
840

941

1042
## 解法

solution/0600-0699/0616.Add Bold Tag in String/README_EN.md

+34-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,40 @@
33
[中文文档](/solution/0600-0699/0616.Add%20Bold%20Tag%20in%20String/README.md)
44

55
## Description
6-
None
6+
Given a string <b>s</b> and a list of strings <b>dict</b>, you need to add a closed pair of bold tag <code><b></code> and <code></b></code> to wrap the substrings in s that exist in dict. If two such substrings overlap, you need to wrap them together by only one pair of closed bold tag. Also, if two substrings wrapped by bold tags are consecutive, you need to combine them.
7+
<p><b>Example 1:</b></p>
8+
9+
<pre>
10+
<b>Input:</b>
11+
s = "abcxyz123"
12+
dict = ["abc","123"]
13+
<b>Output:</b>
14+
"<b>abc</b>xyz<b>123</b>"
15+
</pre>
16+
17+
<p> </p>
18+
19+
<p><b>Example 2:</b></p>
20+
21+
<pre>
22+
<b>Input:</b>
23+
s = "aaabbcc"
24+
dict = ["aaa","aab","bc"]
25+
<b>Output:</b>
26+
"<b>aaabbc</b>c"
27+
</pre>
28+
29+
<p> </p>
30+
31+
<p><b>Constraints:</b></p>
32+
33+
<ul>
34+
<li>The given dict won't contain duplicates, and its length won't exceed 100.</li>
35+
<li>All the strings in input have length in range [1, 1000].</li>
36+
</ul>
37+
38+
<p><strong>Note:</strong> This question is the same as 758: <a href="https://leetcode.com/problems/bold-words-in-string/">https://leetcode.com/problems/bold-words-in-string/</a></p>
39+
740

841

942
## Solutions

solution/0600-0699/0624.Maximum Distance in Arrays/README.md

+25-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,31 @@
44

55
## 题目描述
66
<!-- 这里写题目描述 -->
7-
None
7+
<p>给定 <code>m</code> 个数组,每个数组都已经按照升序排好序了。现在你需要从两个不同的数组中选择两个整数(每个数组选一个)并且计算它们的距离。两个整数 <code>a</code> 和 <code>b</code> 之间的距离定义为它们差的绝对值 <code>|a-b|</code> 。你的任务就是去找到最大距离</p>
8+
9+
<p><strong>示例 1:</strong></p>
10+
11+
<pre><strong>输入:</strong>
12+
[[1,2,3],
13+
[4,5],
14+
[1,2,3]]
15+
<strong>输出:</strong> 4
16+
<strong>解释:</strong>
17+
一种得到答案 4 的方法是从第一个数组或者第三个数组中选择 1,同时从第二个数组中选择 5 。
18+
</pre>
19+
20+
<p> </p>
21+
22+
<p><strong>注意:</strong></p>
23+
24+
<ol>
25+
<li>每个给定数组至少会有 1 个数字。列表中至少有两个非空数组。</li>
26+
<li><strong>所有</strong> <code>m</code> 个数组中的数字总数目在范围 [2, 10000] 内。</li>
27+
<li><code>m</code> 个数组中所有整数的范围在 [-10000, 10000] 内。</li>
28+
</ol>
29+
30+
<p> </p>
31+
832

933

1034
## 解法

solution/0600-0699/0624.Maximum Distance in Arrays/README_EN.md

+23-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,29 @@
33
[中文文档](/solution/0600-0699/0624.Maximum%20Distance%20in%20Arrays/README.md)
44

55
## Description
6-
None
6+
<p>
7+
Given <code>m</code> arrays, and each array is sorted in ascending order. Now you can pick up two integers from two different arrays (each array picks one) and calculate the distance. We define the distance between two integers <code>a</code> and <code>b</code> to be their absolute difference <code>|a-b|</code>. Your task is to find the maximum distance.
8+
</p>
9+
10+
<p><b>Example 1:</b><br />
11+
<pre>
12+
<b>Input:</b>
13+
[[1,2,3],
14+
[4,5],
15+
[1,2,3]]
16+
<b>Output:</b> 4
17+
<b>Explanation:</b>
18+
One way to reach the maximum distance 4 is to pick 1 in the first or third array and pick 5 in the second array.
19+
</pre>
20+
</p>
21+
22+
<p><b>Note:</b><br>
23+
<ol>
24+
<li>Each given array will have at least 1 number. There will be at least two non-empty arrays.</li>
25+
<li>The total number of the integers in <b>all</b> the <code>m</code> arrays will be in the range of [2, 10000].</li>
26+
<li>The integers in the <code>m</code> arrays will be in the range of [-10000, 10000].</li>
27+
</ol>
28+
</p>
729

830

931
## Solutions

solution/0600-0699/0625.Minimum Factorization/README.md

+32-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,38 @@
44

55
## 题目描述
66
<!-- 这里写题目描述 -->
7-
None
7+
<p>给定一个正整数 <code>a</code>,找出最小的正整数 <code>b</code> 使得 <code>b</code> 的所有数位相乘恰好等于 <code>a</code>。</p>
8+
9+
<p>如果不存在这样的结果或者结果不是 32 位有符号整数,返回 0。</p>
10+
11+
<p> </p>
12+
13+
<p><strong>样例 1</strong></p>
14+
15+
<p>输入:</p>
16+
17+
<pre>48
18+
</pre>
19+
20+
<p>输出:</p>
21+
22+
<pre>68</pre>
23+
24+
<p> </p>
25+
26+
<p><strong>样例 2</strong></p>
27+
28+
<p>输入:</p>
29+
30+
<pre>15
31+
</pre>
32+
33+
<p>输出:</p>
34+
35+
<pre>35</pre>
36+
37+
<p> </p>
38+
839

940

1041
## 解法

solution/0600-0699/0625.Minimum Factorization/README_EN.md

+21-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,27 @@
33
[中文文档](/solution/0600-0699/0625.Minimum%20Factorization/README.md)
44

55
## Description
6-
None
6+
<p>Given a positive integer <code>a</code>, find the smallest positive integer <code>b</code> whose multiplication of each digit equals to <code>a</code>. </p>
7+
8+
<p>
9+
If there is no answer or the answer is not fit in 32-bit signed integer, then return 0.</p>
10+
11+
<p>
12+
<b>Example 1</b><br>
13+
Input:
14+
<pre>48 </pre>
15+
Output:
16+
<pre>68</pre>
17+
</p>
18+
19+
<p>
20+
<b>Example 2</b><br>
21+
Input:
22+
<pre>15</pre>
23+
24+
Output:
25+
<pre>35</pre>
26+
</p>
727

828

929
## Solutions

solution/0600-0699/0631.Design Excel Sum Formula/README.md

+65-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,71 @@
44

55
## 题目描述
66
<!-- 这里写题目描述 -->
7-
None
7+
<p>你的任务是实现 Excel 的求和功能,具体的操作如下:</p>
8+
9+
<p><code>Excel(int H, char W):</code> 这是一个构造函数,输入表明了 Excel 的高度和宽度。H 是一个正整数,范围从 1 到 26,代表高度。W 是一个字符,范围从 'A' 到 'Z',宽度等于从 'A' 到 W 的字母个数。Excel 表格是一个高度 * 宽度的二维整数数组,数组中元素初始化为 0。第一行下标从 1 开始,第一列下标从 'A' 开始。</p>
10+
11+
<p> </p>
12+
13+
<p><code>void Set(int row, char column, int val):</code> 设置 <code>C(row, column)</code> 中的值为 val。</p>
14+
15+
<p> </p>
16+
17+
<p><code>int Get(int row, char column):</code> 返回 <code>C(row, column)</code> 中的值。</p>
18+
19+
<p> </p>
20+
21+
<p><code>int Sum(int row, char column, List of Strings : numbers):</code> 这个函数会将计算的结果放入 <code>C(row, column)</code> 中,计算的结果等于在 <code>numbers</code> 中代表的所有元素之和,这个函数同时也会将这个结果返回。求和公式会一直计算更新结果直到这个公式被其他的值或者公式覆盖。</p>
22+
23+
<p><code>numbers</code> 是若干字符串的集合,每个字符串代表单个位置或一个区间。如果这个字符串表示单个位置,它的格式如下:<code>ColRow</code>,例如 "F7" 表示位置 (7, F) 。如果这个字符串表示一个区间,它的格式如下:<code>ColRow1:ColRow2</code>。区间就是左上角为 ColRow1 右下角为 ColRow2 的长方形。</p>
24+
25+
<p> </p>
26+
27+
<p><strong>样例 1 :</strong></p>
28+
29+
<p> </p>
30+
31+
<pre>Excel(3,"C");
32+
// 构造一个 3*3 的二维数组,初始化全是 0。
33+
// A B C
34+
// 1 0 0 0
35+
// 2 0 0 0
36+
// 3 0 0 0
37+
38+
Set(1, "A", 2);
39+
// 设置 C(1,"A") 为 2。
40+
// A B C
41+
// 1 2 0 0
42+
// 2 0 0 0
43+
// 3 0 0 0
44+
45+
Sum(3, "C", ["A1", "A1:B2"]);
46+
// 将 C(3,"C") 的值设为 C(1,"A") 单点,左上角为 C(1,"A") 右下角为 C(2,"B") 的长方形,所有元素之和。返回值 4。
47+
// A B C
48+
// 1 2 0 0
49+
// 2 0 0 0
50+
// 3 0 0 4
51+
52+
Set(2, "B", 2);
53+
// 将 C(2,"B") 设为 2。 注意 C(3, "C") 的值也同时改变。
54+
// A B C
55+
// 1 2 0 0
56+
// 2 0 2 0
57+
// 3 0 0 6
58+
</pre>
59+
60+
<p> </p>
61+
62+
<p><strong>注释 :</strong></p>
63+
64+
<ol>
65+
<li>你可以认为不会出现循环求和的定义,比如说: A1 = sum(B1) ,B1 = sum(A1)。</li>
66+
<li>测试数据中,字母表示用双引号。</li>
67+
<li>请记住<strong>清零</strong> Excel 类中的变量,因为静态变量、类变量会在多组测试数据中保存之前结果。详情请看<a href="http://leetcode.com/faq/#different-output" target="_blank">这里</a>。</li>
68+
</ol>
69+
70+
<p> </p>
71+
872

973

1074
## 解法

0 commit comments

Comments
 (0)