Skip to content

Commit cd3fc67

Browse files
authored
Create print-words-vertically.py
1 parent 0beb82d commit cd3fc67

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Python/print-words-vertically.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Time: O(n)
2+
# Space: O(h)
3+
4+
import itertools
5+
6+
7+
class Solution(object):
8+
def printVertically(self, s):
9+
"""
10+
:type s: str
11+
:rtype: List[str]
12+
"""
13+
return ["".join(c).rstrip() for c in itertools.izip_longest(*s.split(), fillvalue=' ')]

0 commit comments

Comments
 (0)