|
1 | 1 | [#0816-ambiguous-coordinates] |
2 | | -= 816. Ambiguous Coordinates |
| 2 | += 816. 模糊坐标 |
3 | 3 |
|
4 | | -{leetcode}/problems/ambiguous-coordinates/[LeetCode - Ambiguous Coordinates^] |
| 4 | +https://leetcode.cn/problems/ambiguous-coordinates/[LeetCode - 816. 模糊坐标^] |
5 | 5 |
|
6 | | -We had some 2-dimensional coordinates, like `"(1, 3)"` or `"(2, 0.5)"`. Then, we removed all commas, decimal points, and spaces, and ended up with the string `S`. Return a list of strings representing all possibilities for what our original coordinates could have been. |
| 6 | +我们有一些二维坐标,如 `(1, 3)` 或 `(2, 0.5)`,然后我们移除所有逗号,小数点和空格,得到一个字符串`S`。返回所有可能的原始字符串到一个列表中。 |
7 | 7 |
|
8 | | -Our original representation never had extraneous zeroes, so we never started with numbers like "00", "0.0", "0.00", "1.0", "001", "00.01", or any other number that can be represented with less digits. Also, a decimal point within a number never occurs without at least one digit occuring before it, so we never started with numbers like ".1". |
| 8 | +原始的坐标表示法不会存在多余的零,所以不会出现类似于"00", "0.0", "0.00", "1.0", "001", "00.01"或一些其他更小的数来表示坐标。此外,一个小数点前至少存在一个数,所以也不会出现“.1”形式的数字。 |
9 | 9 |
|
10 | | -The final answer list can be returned in any order. Also note that all coordinates in the final answer have exactly one space between them (occurring after the comma.) |
| 10 | +最后返回的列表可以是任意顺序的。而且注意返回的两个数字中间(逗号之后)都有一个空格。 |
11 | 11 |
|
12 | | -[subs="verbatim,quotes,macros"] |
13 | | ----- |
14 | | -*Example 1:* |
15 | | -*Input:* "(123)" |
16 | | -*Output:* ["(1, 23)", "(12, 3)", "(1.2, 3)", "(1, 2.3)"] |
17 | | ----- |
| 12 | +.... |
| 13 | +示例 1: |
| 14 | +输入: "(123)" |
| 15 | +输出: ["(1, 23)", "(12, 3)", "(1.2, 3)", "(1, 2.3)"] |
| 16 | +.... |
18 | 17 |
|
19 | | -[subs="verbatim,quotes,macros"] |
20 | | ----- |
21 | | -*Example 2:* |
22 | | -*Input:* "(00011)" |
23 | | -*Output:* ["(0.001, 1)", "(0, 0.011)"] |
24 | | -*Explanation:* |
25 | | -0.0, 00, 0001 or 00.01 are not allowed. |
26 | | ----- |
| 18 | +.... |
| 19 | +示例 2: |
| 20 | +输入: "(00011)" |
| 21 | +输出: ["(0.001, 1)", "(0, 0.011)"] |
| 22 | +解释: |
| 23 | +0.0, 00, 0001 或 00.01 是不被允许的。 |
| 24 | +.... |
27 | 25 |
|
28 | | -[subs="verbatim,quotes,macros"] |
29 | | ----- |
30 | | -*Example 3:* |
31 | | -*Input:* "(0123)" |
32 | | -*Output:* ["(0, 123)", "(0, 12.3)", "(0, 1.23)", "(0.1, 23)", "(0.1, 2.3)", "(0.12, 3)"] |
33 | | ----- |
| 26 | +.... |
| 27 | +示例 3: |
| 28 | +输入: "(0123)" |
| 29 | +输出: ["(0, 123)", "(0, 12.3)", "(0, 1.23)", "(0.1, 23)", "(0.1, 2.3)", "(0.12, 3)"] |
| 30 | +.... |
34 | 31 |
|
35 | | -[subs="verbatim,quotes,macros"] |
36 | | ----- |
37 | | -*Example 4:* |
38 | | -*Input:* "(100)" |
39 | | -*Output:* [(10, 0)] |
40 | | -*Explanation:* |
41 | | -1.0 is not allowed. |
42 | | ----- |
| 32 | +.... |
| 33 | +示例 4: |
| 34 | +输入: "(100)" |
| 35 | +输出: [(10, 0)] |
| 36 | +解释: |
| 37 | +1.0 是不被允许的。 |
| 38 | +.... |
43 | 39 |
|
44 | | - |
| 40 | +*提示:* |
45 | 41 |
|
46 | | -*Note: * |
| 42 | +* `4 \<= S.length \<= 12`. |
| 43 | +* `S[0] = (`, `S[S.length - 1] = )`, 且字符串 `S` 中的其他元素都是数字。 |
47 | 44 |
|
48 | 45 |
|
49 | | -* `4 <= S.length <= 12`. |
50 | | -* `S[0]` = "(", `S[S.length - 1]` = ")", and the other elements in `S` are digits. |
51 | 46 |
|
| 47 | +== 思路分析 |
52 | 48 |
|
53 | | - |
| 49 | +将字符串进行分割,然后给每个分割的字符串添加小数点,要排除非法数字的情况。 |
54 | 50 |
|
| 51 | +image::images/0816-10.png[{image_attr}] |
55 | 52 |
|
56 | 53 |
|
57 | 54 | [[src-0816]] |
| 55 | +[tabs] |
| 56 | +==== |
| 57 | +一刷:: |
| 58 | ++ |
| 59 | +-- |
58 | 60 | [{java_src_attr}] |
59 | 61 | ---- |
60 | 62 | include::{sourcedir}/_0816_AmbiguousCoordinates.java[tag=answer] |
61 | 63 | ---- |
| 64 | +-- |
| 65 | +
|
| 66 | +// 二刷:: |
| 67 | +// + |
| 68 | +// -- |
| 69 | +// [{java_src_attr}] |
| 70 | +// ---- |
| 71 | +// include::{sourcedir}/_0816_AmbiguousCoordinates_2.java[tag=answer] |
| 72 | +// ---- |
| 73 | +// -- |
| 74 | +==== |
| 75 | + |
| 76 | + |
| 77 | +== 参考资料 |
62 | 78 |
|
| 79 | +. https://leetcode.cn/problems/ambiguous-coordinates/solutions/1951931/mo-hu-zuo-biao-by-leetcode-solution-y1yz/[816. 模糊坐标 - 官方题解^] |
| 80 | +. https://leetcode.cn/problems/ambiguous-coordinates/solutions/1953793/zhua-wa-mou-si-tu-jie-leetcode-by-muse-7-7y25/[816. 模糊坐标 - 图解LeetCode^] |
0 commit comments