2194. Cells in a Range on an Excel Sheet
Read the full problem statement on LeetCode.
Difficulty: easy Acceptance: 84% Topics: String
View full problem on LeetCode Reading material
Reference solution (spoiler · python)
# Time: O(26^2)
# Space: O(1)
# enumeration
class Solution(object):
def cellsInRange(self, s):
"""
:type s: str
:rtype: List[str]
"""
return [chr(x)+chr(y) for x in xrange(ord(s[0]), ord(s[3])+1) for y in xrange(ord(s[1]), ord(s[4])+1)]
Solution from kamyu104/LeetCode-Solutions · MIT