Cells in a Range on an Excel Sheet LeetCode solution in Python
1# Runtime: 52 ms (Top 33.3%) | Memory: 16.43 MB (Top 7.2%)234class Solution:5def cellsInRange(self, s: str) -> List[str]:6start, end = s.split(":")7start_letter, start_num = start[0], int(start[-1])8end_letter, end_num = end[0], int(end[1])9alphabet = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")10alphabet_slice = alphabet[11alphabet.index(start_letter) : alphabet.index(end_letter) + 112]13res = list()14for el in alphabet_slice:15res += [el + str(num) for num in range(start_num, end_num + 1)]16return res