1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (English)/竖直打印单词(English) [print-words-vertically].html

42 lines
1.6 KiB
HTML
Raw Permalink Normal View History

2022-03-27 20:37:52 +08:00
<p>Given a string <code>s</code>.&nbsp;Return&nbsp;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&nbsp;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>&nbsp;</p>
2023-12-09 18:42:21 +08:00
<p><strong class="example">Example 1:</strong></p>
2022-03-27 20:37:52 +08:00
<pre>
<strong>Input:</strong> s = &quot;HOW ARE YOU&quot;
<strong>Output:</strong> [&quot;HAY&quot;,&quot;ORO&quot;,&quot;WEU&quot;]
<strong>Explanation: </strong>Each word is printed vertically.
&quot;HAY&quot;
&nbsp;&quot;ORO&quot;
&nbsp;&quot;WEU&quot;
</pre>
2023-12-09 18:42:21 +08:00
<p><strong class="example">Example 2:</strong></p>
2022-03-27 20:37:52 +08:00
<pre>
<strong>Input:</strong> s = &quot;TO BE OR NOT TO BE&quot;
<strong>Output:</strong> [&quot;TBONTB&quot;,&quot;OEROOE&quot;,&quot; T&quot;]
<strong>Explanation: </strong>Trailing spaces is not allowed.
&quot;TBONTB&quot;
&quot;OEROOE&quot;
&quot; T&quot;
</pre>
2023-12-09 18:42:21 +08:00
<p><strong class="example">Example 3:</strong></p>
2022-03-27 20:37:52 +08:00
<pre>
<strong>Input:</strong> s = &quot;CONTEST IS COMING&quot;
<strong>Output:</strong> [&quot;CIC&quot;,&quot;OSO&quot;,&quot;N M&quot;,&quot;T I&quot;,&quot;E N&quot;,&quot;S G&quot;,&quot;T&quot;]
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 &lt;= s.length &lt;= 200</code></li>
<li><code>s</code>&nbsp;contains only upper case English letters.</li>
<li>It&#39;s guaranteed that there is only one&nbsp;space between 2 words.</li>
</ul>