2194. Cells in a Range on an Excel Sheet Easy
1/**
2 * [2194] Cells in a Range on an Excel Sheet
3 *
4 * A cell (r, c) of an excel sheet is represented as a string "<col><row>" where:
5 *
6 * <col> denotes the column number c of the cell. It is represented by alphabetical letters.
7 *
8 * For example, the 1^st column is denoted by 'A', the 2^nd by 'B', the 3^rd by 'C', and so on.
9 *
10 *
11 * <row> is the row number r of the cell. The r^th row is represented by the integer r.
12 *
13 * 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.
14 * 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.
15 *
16 * Example 1:
17 * <img alt="" src="https://assets.leetcode.com/uploads/2022/02/08/ex1drawio.png" style="width: 250px; height: 160px;" />
18 * Input: s = "K1:L2"
19 * Output: ["K1","K2","L1","L2"]
20 * Explanation:
21 * The above diagram shows the cells which should be present in the list.
22 * The red arrows denote the order in which the cells should be presented.
23 *
24 * Example 2:
25 * <img alt="" src="https://assets.leetcode.com/uploads/2022/02/09/exam2drawio.png" style="width: 500px; height: 50px;" />
26 * Input: s = "A1:F1"
27 * Output: ["A1","B1","C1","D1","E1","F1"]
28 * Explanation:
29 * The above diagram shows the cells which should be present in the list.
30 * The red arrow denotes the order in which the cells should be presented.
31 *
32 *
33 * Constraints:
34 *
35 * s.length == 5
36 * 'A' <= s[0] <= s[3] <= 'Z'
37 * '1' <= s[1] <= s[4] <= '9'
38 * s consists of uppercase English letters, digits and ':'.
39 *
40 */
41pub struct Solution {}
42
43// problem: https://leetcode.com/problems/cells-in-a-range-on-an-excel-sheet/
44// discuss: https://leetcode.com/problems/cells-in-a-range-on-an-excel-sheet/discuss/?currentPage=1&orderBy=most_votes&query=
45
46// submission codes start here
47
48impl Solution {
49 pub fn cells_in_range(s: String) -> Vec<String> {
50 vec![]
51 }
52}
53
54// submission codes end
55
56#[cfg(test)]
57mod tests {
58 use super::*;
59
60 #[test]
61 fn test_2194() {
62 }
63}
64
Back
© 2025 bowen.ge All Rights Reserved.