File size: 6,285 Bytes
f7c0146
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
{
    "id": 2304,
    "name": "cells_in_a_range_on_an_excel_sheet",
    "difficulty": "Easy",
    "link": "https://leetcode.com/problems/cells-in-a-range-on-an-excel-sheet/",
    "date": "1645920000000",
    "task_description": "A cell `(r, c)` of an excel sheet is represented as a string `\"<col><row>\"` where: `<col>` denotes the column number `c` of the cell. It is represented by **alphabetical letters**. For example, the `1st` column is denoted by `'A'`, the `2nd` by `'B'`, the `3rd` by `'C'`, and so on. `<row>` is the row number `r` of the cell. The `rth` row is represented by the **integer** `r`. You are given a string `s` in the format `\"<col1><row1>:<col2><row2>\"`, where `<col1>` represents the column `c1`, `<row1>` represents the row `r1`, `<col2>` represents the column `c2`, and `<row2>` represents the row `r2`, such that `r1 <= r2` and `c1 <= c2`. Return _the **list of cells**_ `(x, y)` _such that_ `r1 <= x <= r2` _and_ `c1 <= y <= c2`. The cells should be represented as **strings** in the format mentioned above and be sorted in **non-decreasing** order first by columns and then by rows. **Example 1:** ``` **Input:** s = \"K1:L2\" **Output:** [\"K1\",\"K2\",\"L1\",\"L2\"] **Explanation:** The above diagram shows the cells which should be present in the list. The red arrows denote the order in which the cells should be presented. ``` **Example 2:** ``` **Input:** s = \"A1:F1\" **Output:** [\"A1\",\"B1\",\"C1\",\"D1\",\"E1\",\"F1\"] **Explanation:** The above diagram shows the cells which should be present in the list. The red arrow denotes the order in which the cells should be presented. ``` **Constraints:** `s.length == 5` `'A' <= s[0] <= s[3] <= 'Z'` `'1' <= s[1] <= s[4] <= '9'` `s` consists of uppercase English letters, digits and `':'`.",
    "public_test_cases": [
        {
            "label": "Example 1",
            "input": "s = \"K1:L2\"",
            "output": "[\"K1\",\"K2\",\"L1\",\"L2\"] "
        },
        {
            "label": "Example 2",
            "input": "s = \"A1:F1\"",
            "output": "[\"A1\",\"B1\",\"C1\",\"D1\",\"E1\",\"F1\"] "
        }
    ],
    "private_test_cases": [
        {
            "input": "\"C8:D8\"",
            "output": [
                "C8",
                "D8"
            ]
        },
        {
            "input": "\"S9:V9\"",
            "output": [
                "S9",
                "T9",
                "U9",
                "V9"
            ]
        },
        {
            "input": "\"Y6:Y9\"",
            "output": [
                "Y6",
                "Y7",
                "Y8",
                "Y9"
            ]
        },
        {
            "input": "\"U9:W9\"",
            "output": [
                "U9",
                "V9",
                "W9"
            ]
        },
        {
            "input": "\"H2:O7\"",
            "output": [
                "H2",
                "H3",
                "H4",
                "H5",
                "H6",
                "H7",
                "I2",
                "I3",
                "I4",
                "I5",
                "I6",
                "I7",
                "J2",
                "J3",
                "J4",
                "J5",
                "J6",
                "J7",
                "K2",
                "K3",
                "K4",
                "K5",
                "K6",
                "K7",
                "L2",
                "L3",
                "L4",
                "L5",
                "L6",
                "L7",
                "M2",
                "M3",
                "M4",
                "M5",
                "M6",
                "M7",
                "N2",
                "N3",
                "N4",
                "N5",
                "N6",
                "N7",
                "O2",
                "O3",
                "O4",
                "O5",
                "O6",
                "O7"
            ]
        },
        {
            "input": "\"N6:O8\"",
            "output": [
                "N6",
                "N7",
                "N8",
                "O6",
                "O7",
                "O8"
            ]
        },
        {
            "input": "\"Q1:S8\"",
            "output": [
                "Q1",
                "Q2",
                "Q3",
                "Q4",
                "Q5",
                "Q6",
                "Q7",
                "Q8",
                "R1",
                "R2",
                "R3",
                "R4",
                "R5",
                "R6",
                "R7",
                "R8",
                "S1",
                "S2",
                "S3",
                "S4",
                "S5",
                "S6",
                "S7",
                "S8"
            ]
        },
        {
            "input": "K9:T9",
            "output": [
                "K9",
                "L9",
                "M9",
                "N9",
                "O9",
                "P9",
                "Q9",
                "R9",
                "S9",
                "T9"
            ]
        },
        {
            "input": "W6:W8",
            "output": [
                "W6",
                "W7",
                "W8"
            ]
        },
        {
            "input": "O5:S8",
            "output": [
                "O5",
                "O6",
                "O7",
                "O8",
                "P5",
                "P6",
                "P7",
                "P8",
                "Q5",
                "Q6",
                "Q7",
                "Q8",
                "R5",
                "R6",
                "R7",
                "R8",
                "S5",
                "S6",
                "S7",
                "S8"
            ]
        }
    ],
    "haskell_template": "cellsInRange :: String -> [String]\ncellsInRange s ",
    "ocaml_template": "let cellsInRange (s: string) : string list =  ",
    "scala_template": "def cellsInRange(s: String): List[String] = { \n    \n}",
    "java_template": "public static List<String> cellsInRange(String s) {\n\n}",
    "python_template": "class Solution(object):\n    def cellsInRange(self, s):\n        \"\"\"\n        :type s: str\n        :rtype: List[str]\n        \"\"\"\n        "
}