Leetcode 1449 Solution
This article provides solution to leetcode question 1449 (print-words-vertically)
Access this page by simply typing in "lcs 1449" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/print-words-vertically
Solution
class Solution:
def printVertically(self, s: str) -> List[str]:
i = 0
tokens = s.split(" ")
ans = []
while True:
v = ""
for token in tokens:
if i < len(token):
v += token[i]
else:
v += " "
v = v.rstrip(" ")
if not v:
break
ans.append(v)
i += 1
return ans