|
| 1 | +2194\. Cells in a Range on an Excel Sheet |
| 2 | + |
| 3 | +Easy |
| 4 | + |
| 5 | +A cell `(r, c)` of an excel sheet is represented as a string `"<col><row>"` where: |
| 6 | + |
| 7 | +* `<col>` denotes the column number `c` of the cell. It is represented by **alphabetical letters**. |
| 8 | + * For example, the <code>1<sup>st</sup></code> column is denoted by `'A'`, the <code>2<sup>nd</sup></code> by `'B'`, the <code>3<sup>rd</sup></code> by `'C'`, and so on. |
| 9 | +* `<row>` is the row number `r` of the cell. The <code>r<sup>th</sup></code> row is represented by the **integer** `r`. |
| 10 | + |
| 11 | +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`. |
| 12 | + |
| 13 | +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. |
| 14 | + |
| 15 | +**Example 1:** |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | +**Input:** s = "K1:L2" |
| 20 | + |
| 21 | +**Output:** ["K1","K2","L1","L2"] |
| 22 | + |
| 23 | +**Explanation:** |
| 24 | + |
| 25 | +The above diagram shows the cells which should be present in the list. |
| 26 | + |
| 27 | +The red arrows denote the order in which the cells should be presented. |
| 28 | + |
| 29 | +**Example 2:** |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | +**Input:** s = "A1:F1" |
| 34 | + |
| 35 | +**Output:** ["A1","B1","C1","D1","E1","F1"] |
| 36 | + |
| 37 | +**Explanation:** |
| 38 | + |
| 39 | +The above diagram shows the cells which should be present in the list. |
| 40 | + |
| 41 | +The red arrow denotes the order in which the cells should be presented. |
| 42 | + |
| 43 | +**Constraints:** |
| 44 | + |
| 45 | +* `s.length == 5` |
| 46 | +* `'A' <= s[0] <= s[3] <= 'Z'` |
| 47 | +* `'1' <= s[1] <= s[4] <= '9'` |
| 48 | +* `s` consists of uppercase English letters, digits and `':'`. |
0 commit comments