1324. Print Words Vertically
Read the full problem statement on LeetCode.
Difficulty: medium Acceptance: 66% Topics: Array, String, Simulation
View full problem on LeetCode Reading material
Reference solution (spoiler · python)
# Time: O(n)
# Space: O(n)
import itertools
class Solution(object):
def printVertically(self, s):
"""
:type s: str
:rtype: List[str]
"""
return ["".join(c).rstrip() for c in itertools.izip_longest(*s.split(), fillvalue=' ')]
Solution from kamyu104/LeetCode-Solutions · MIT