Class Solution
- java.lang.Object
-
- g2101_2200.s2194_cells_in_a_range_on_an_excel_sheet.Solution
-
public class Solution extends Object
2194 - Cells in a Range on an Excel Sheet.Easy
A cell
(r, c)of an excel sheet is represented as a string"<col><row>"where:<col>denotes the column numbercof the cell. It is represented by alphabetical letters.- For example, the
1stcolumn is denoted by'A', the2ndby'B', the3rdby'C', and so on.
- For example, the
<row>is the row numberrof the cell. Therthrow is represented by the integerr.
You are given a string
sin the format"<col1><row1>:<col2><row2>", where<col1>represents the columnc1,<row1>represents the rowr1,<col2>represents the columnc2, and<row2>represents the rowr2, such thatr1 <= r2andc1 <= c2.Return the list of cells
(x, y)such thatr1 <= x <= r2andc1 <= 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'sconsists of uppercase English letters, digits and':'.
-
-
Constructor Summary
Constructors Constructor Description Solution()
-