Skip to content
LC-1324 Medium LeetCode

1324. Print Words Vertically

Read the full problem statement on LeetCode.
Difficulty: medium Acceptance: 66% Topics: Array, String, Simulation
View full problem on LeetCode
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