Skip to content

Practice Cells in a Range on an Excel Sheet

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#2194
LeetCode Problem

Cells in a Range on an Excel Sheet

Problem Statement

A cell name combines its column letter followed by its row number: A is column 1, B is column 2, and so on. Given the inclusive rectangular range s in the form col1row1:col2row2, return every cell name in the range. List columns in increasing order, and within each column list rows in increasing order. The starting row and column do not exceed the ending ones.

Source: Cells in a Range on an Excel Sheet on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
s = "K1:L2"
Output
["K1","K2","L1","L2"]

# Example 2

Input
s = "A1:F1"
Output
["A1","B1","C1","D1","E1","F1"]

Constraints

s.length == 5
'A' <= s[0] <= s[3] <= 'Z'
'1' <= s[1] <= s[4] <= '9'
s consists of uppercase English letters, digits and ':'.

Related LeetCode Problems

Practice more problems similar to Cells in a Range on an Excel Sheet.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.