Class Solution

java.lang.Object
g1301_1400.s1324_print_words_vertically.Solution

public class Solution extends Object
1324 - Print Words Vertically.<p>Medium</p> <p>Given a string <code>s</code>. Return all the words vertically in the same order in which they appear in <code>s</code>.<br /> Words are returned as a list of strings, complete with spaces when is necessary. (Trailing spaces are not allowed).<br /> Each word would be put on only one column and that in one column there will be only one word.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> s = &ldquo;HOW ARE YOU&rdquo;</p> <p><strong>Output:</strong> [&ldquo;HAY&rdquo;,&ldquo;ORO&rdquo;,&ldquo;WEU&rdquo;]</p> <p><strong>Explanation:</strong> Each word is printed vertically.</p> <p>&ldquo;HAY&rdquo;</p> <p>&ldquo;ORO&rdquo;</p> <p>&ldquo;WEU&rdquo;</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> s = &ldquo;TO BE OR NOT TO BE&rdquo;</p> <p><strong>Output:</strong> [&ldquo;TBONTB&rdquo;,&ldquo;OEROOE&rdquo;,&quot; T&quot;]</p> <p><strong>Explanation:</strong> Trailing spaces is not allowed.</p> <p>&ldquo;TBONTB&rdquo;</p> <p>&ldquo;OEROOE&rdquo;</p> <p>&quot; T&quot;</p> <p><strong>Example 3:</strong></p> <p><strong>Input:</strong> s = &ldquo;CONTEST IS COMING&rdquo;</p> <p><strong>Output:</strong> [&ldquo;CIC&rdquo;,&ldquo;OSO&rdquo;,&ldquo;N M&rdquo;,&ldquo;T I&rdquo;,&ldquo;E N&rdquo;,&ldquo;S G&rdquo;,&ldquo;T&rdquo;]</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= s.length <= 200</code></li> <li><code>s</code> contains only upper case English letters.</li> <li>It&rsquo;s guaranteed that there is only one space between 2 words.</li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details