Skip to content

Commit 212aa1f

Browse files
committed
Update: problems descriptions
1 parent a72c1b9 commit 212aa1f

File tree

6 files changed

+194
-37
lines changed

6 files changed

+194
-37
lines changed

src/problems/p000_0xx/p000_005.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,28 @@
22
///
33
/// It's possible to have multiple correct answer.
44
/// See `tests/cases/c000_0xx/c000_005.rs` for more info.
5+
///
6+
/// ### Description
7+
///
8+
/// Given a string `s`, return the longest palindromic substring in `s`.
9+
///
10+
/// | Example 1 |
11+
/// | :-- |
12+
/// | Input: s = "babad" |
13+
/// | Output: "bab" |
14+
///
15+
/// Explanation: "aba" is also a valid answer.
16+
///
17+
/// | Example 2 |
18+
/// | :-- |
19+
/// | Input: s = "cbbd" |
20+
/// | Output: "bb" |
21+
///
22+
/// Constraints:
23+
/// - `1 <= s.length <= 1000`
24+
/// - `s` consist of only digits and English letters.
25+
///
26+
/// Source: https://leetcode.com/problems/longest-palindromic-substring/
527
///
628
/// ### Arguments
729
/// * `s` - original string to search.

src/problems/p000_0xx/p000_006.rs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,56 @@ pub enum Algorithm {
66
/// Get a ZigZag matrix using given string and column-first algorithm.
77
///
88
/// Two solutions available, use second argument to decide which to use.
9+
///
10+
/// ### Description
11+
///
12+
/// The string "PAYPALISHIRING" is written in a zigzag pattern on a given
13+
/// number of rows like this: (you may want to display this pattern in a fixed
14+
/// font for better legibility)
15+
///
16+
/// ```plain
17+
/// P A H N
18+
/// A P L S I I G
19+
/// Y I R
20+
/// ```
21+
///
22+
/// And then read line by line: "PAHNAPLSIIGYIR"
23+
///
24+
/// Write the code that will take a string and make this conversion given a
25+
/// number of rows:
26+
///
27+
/// string convert(string `s`, int `numRows`);
28+
///
29+
/// | Example 1 |
30+
/// | :-- |
31+
/// | Input: s = "PAYPALISHIRING", numRows = 3 |
32+
/// | Output: "PAHNAPLSIIGYIR" |
33+
///
34+
/// | Example 2 |
35+
/// | :-- |
36+
/// | Input: s = "PAYPALISHIRING", numRows = 4 |
37+
/// | Output: "PINALSIGYAHRPI" |
38+
///
39+
/// Explanation:
40+
/// ```plain
41+
/// P I N
42+
/// A L S I G
43+
/// Y A H R
44+
/// P I
45+
/// ```
46+
///
47+
/// | Example 3 |
48+
/// | :-- |
49+
/// | Input: s = "A", numRows = 1 |
50+
/// | Output: "A" |
51+
///
52+
///
53+
/// Constraints:
54+
/// - `1 <= s.length <= 1000`
55+
/// - `s` consists of English letters (lower-case and upper-case), ',' and '.'.
56+
/// - `1 <= numRows <= 1000`
57+
///
58+
/// Source: https://leetcode.com/problems/zigzag-conversion/
959
///
1060
/// ### Arguments
1161
/// * `s` - original string to convert.

src/problems/p000_0xx/p000_007.rs

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,33 @@
55
///
66
/// ### Description
77
///
8-
/// Given a signed 32-bit integer x, return x with its digits reversed.
9-
/// If reversing x causes the value to go outside the signed 32-bit integer
10-
/// range [-231, 231 - 1], then return 0.
8+
/// Given a signed 32-bit integer `x`, return `x` with its digits reversed.
9+
/// If reversing `x` causes the value to go outside the signed 32-bit integer
10+
/// range \[-2^31, 2^31 - 1\], then return 0.
1111
///
12-
/// Assume the environment does not allow you to store 64-bit integers (signed or /// unsigned).
12+
/// Assume the environment does not allow you to store 64-bit integers (signed
13+
/// or unsigned).
1314
///
14-
///
15-
///
16-
/// Example 1:
17-
///
18-
/// Input: x = 123
19-
/// Output: 321
20-
/// Example 2:
2115
///
22-
/// Input: x = -123
23-
/// Output: -321
24-
/// Example 3:
16+
/// | Example 1 |
17+
/// | :-- |
18+
/// | Input: x = 123 |
19+
/// | Output: 321 |
2520
///
26-
/// Input: x = 120
27-
/// Output: 21
21+
/// | Example 2 |
22+
/// | :-- |
23+
/// | Input: x = -123 |
24+
/// | Output: -321 |
25+
///
26+
/// | Example 3 |
27+
/// | :-- |
28+
/// | Input: x = 120 |
29+
/// | Output: 21 |
2830
///
2931
///
3032
/// Constraints:
3133
///
32-
/// -231 <= x <= 231 - 1
34+
/// - `-2^31 <= x <= 2^31 - 1`
3335
///
3436
/// Source: https://leetcode.com/problems/reverse-integer/description/
3537
///

src/problems_cn/p000_0xx/p000_005.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,33 @@
22
///
33
/// 可能出现同一个字符串有多个最长回文子串的现象
44
/// 参照 `tests/cases_cn/c000_0xx/c000_005.rs` 了解测试用例
5+
///
6+
/// ### 题目描述
7+
///
8+
/// 给你一个字符串 `s`,找到 `s` 中最长的回文子串。
9+
///
10+
/// 如果字符串的反序与原始字符串相同,则该字符串称为回文字符串。
11+
///
12+
/// | 示例 1 |
13+
/// | :-- |
14+
/// | 输入:s = "babad" |
15+
/// | 输出:"bab" |
16+
///
17+
/// 解释:"aba" 同样是符合题意的答案。
18+
///
19+
/// | 示例 2 |
20+
/// | :-- |
21+
/// | 输入:s = "cbbd" |
22+
/// | 输出:"bb" |
23+
///  
24+
///
25+
/// 提示:
26+
/// - `1 <= s.length <= 1000`
27+
/// - `s` 仅由数字和英文字母组成
28+
///
29+
/// 来源:力扣(LeetCode)
30+
/// 链接:https://leetcode.cn/problems/longest-palindromic-substring
31+
/// 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。
532
///
633
/// ### Arguments
734
/// * `s` - 待搜索的原始字符串.

src/problems_cn/p000_0xx/p000_006.rs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,60 @@ pub enum Algorithm {
66
/// Z 字形变换
77
///
88
/// 可以通过第三个参数选择要使用的算法
9+
///
10+
/// ### 题目描述
11+
///
12+
/// 将一个给定字符串 `s` 根据给定的行数 `numRows` ,以从上往下、从左到右进行 Z 字形排列。
13+
///
14+
/// 比如输入字符串为 "PAYPALISHIRING" 行数为 3 时,排列如下:
15+
///
16+
/// ```plain
17+
/// P A H N
18+
/// A P L S I I G
19+
/// Y I R
20+
/// ```
21+
///
22+
/// 之后,你的输出需要从左往右逐行读取,产生出一个新的字符串,比如:"PAHNAPLSIIGYIR"。
23+
///
24+
/// 请你实现这个将字符串进行指定行数变换的函数:
25+
///
26+
/// `string convert(string s, int numRows);`
27+
///  
28+
///
29+
/// | 示例 1 |
30+
/// | :-- |
31+
/// | 输入:s = "PAYPALISHIRING", numRows = 3 |
32+
/// | 输出:"PAHNAPLSIIGYIR" |
33+
///
34+
/// | 示例 2 |
35+
/// | :-- |
36+
/// | 输入:s = "PAYPALISHIRING", numRows = 4 |
37+
/// | 输出:"PINALSIGYAHRPI" |
38+
///
39+
///
40+
/// 解释:
41+
///
42+
/// ```plain
43+
/// P I N
44+
/// A L S I G
45+
/// Y A H R
46+
/// P I
47+
/// ```
48+
///
49+
/// | 示例 3 |
50+
/// | :-- |
51+
/// | 输入: s = "A", numRows = 1 |
52+
/// | 输出:"A" |
53+
///  
54+
/// 提示:
55+
///
56+
/// - `1 <= s.length <= 1000`
57+
/// - `s` 由英文字母(小写和大写)、',' 和 '.' 组成
58+
/// - `1 <= numRows <= 1000`
59+
///
60+
/// 来源:力扣(LeetCode)
61+
/// 链接:https://leetcode.cn/problems/zigzag-conversion
62+
/// 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。
963
///
1064
/// ### Arguments
1165
/// * `s` - 等待变换的字符串

src/problems_cn/p000_0xx/p000_007.rs

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,36 @@
11
/// 32 位整型反转的同时检查溢出
22
///
33
/// ### 题目说明
4-
/// 给你一个 32 位的有符号整数 x ,返回将 x 中的数字部分反转后的结果。
4+
/// 给你一个 32 位的有符号整数 `x` ,返回将 `x` 中的数字部分反转后的结果。
55
///
6-
/// 如果反转后整数超过 32 位的有符号整数的范围 [−231231 − 1] ,就返回 0。
6+
/// 如果反转后整数超过 32 位的有符号整数的范围 [−2^312^31 − 1] ,就返回 0。
77
///
88
/// 假设环境不允许存储 64 位整数(有符号或无符号)。
99
///
1010
///
11-
/// 示例 1:
12-
///
13-
/// 输入:x = 123
14-
/// 输出:321
15-
/// 示例 2:
16-
///
17-
/// 输入:x = -123
18-
/// 输出:-321
19-
/// 示例 3:
20-
///
21-
/// 输入:x = 120
22-
/// 输出:21
23-
/// 示例 4:
24-
///
25-
/// 输入:x = 0
26-
/// 输出:0
27-
///
11+
/// | 示例 1 |
12+
/// | :-- |
13+
/// | 输入:x = 123 |
14+
/// | 输出:321 |
15+
///
16+
/// | 示例 2 |
17+
/// | :-- |
18+
/// | 输入:x = -123 |
19+
/// | 输出:-321 |
20+
///
21+
/// | 示例 3 |
22+
/// | :-- |
23+
/// | 输入:x = 120 |
24+
/// | 输出:21 |
25+
///
26+
/// | 示例 4 |
27+
/// | :-- |
28+
/// | 输入:x = 0 |
29+
/// | 输出:0 |
2830
///
2931
/// 提示:
3032
///
31-
/// -231 <= x <= 231 - 1
33+
/// - `-2^31 <= x <= 2^31 - 1`
3234
///
3335
/// 来源:力扣(LeetCode)
3436
/// 链接:https://leetcode.cn/problems/reverse-integer

0 commit comments

Comments
 (0)