Vertical Word Arrangement
You are given a string s
containing lowercase alphabet characters separated by spaces " "
. After splitting the string on spaces, return all the words in vertical order, top to bottom. If there’s no character on a column, use a space.
Constraints
1 ≤ n ≤ 1,000
wheren
is the length ofs
https://binarysearch.com/problems/Vertical-Word-Arrangement
Examples
Example 1
Input
- s =
abc def ghij
Output
- answer =
['adg', 'beh', 'cfi', ' j']
Explanation
After splitting the string we get
[
"abc",
"def",
"ghij"
]
Then, traversing vertically we can group them into "adg"
, "beh"
, "cfi"
, " j"
.
Leave a comment