3566. Find the Sequence of Strings Appeared on the Screen
My accepted Python solution to LeetCode problem 3566, Find the Sequence of Strings Appeared on the Screen, running in 21ms.
- Difficulty: Medium
- Python
- Runtime 21ms
- Memory 26.5MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 21ms, memory 26.5MB, accepted 2025-12-31.
class Solution:
def stringSequence(self, target: str) -> List[str]:
result = []
current = ""
for char in target:
# First, append 'a' to current string
current += 'a'
result.append(current)
# Then change last character until we reach target char
while current[-1] != char:
# Increment last character
current = current[:-1] + chr(ord(current[-1]) + 1)
result.append(current)
return result