1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/竖直打印单词 [print-words-vertically].html
2022-03-29 12:43:11 +08:00

42 lines
1.5 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给你一个字符串&nbsp;<code>s</code>。请你按照单词在 <code>s</code> 中的出现顺序将它们全部竖直返回。<br>
单词应该以字符串列表的形式返回,必要时用空格补位,但输出尾部的空格需要删除(不允许尾随空格)。<br>
每个单词只能放在一列上,每一列中也只能有一个单词。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre><strong>输入:</strong>s = &quot;HOW ARE YOU&quot;
<strong>输出:</strong>[&quot;HAY&quot;,&quot;ORO&quot;,&quot;WEU&quot;]
<strong>解释:</strong>每个单词都应该竖直打印。
&quot;HAY&quot;
&nbsp;&quot;ORO&quot;
&nbsp;&quot;WEU&quot;
</pre>
<p><strong>示例 2</strong></p>
<pre><strong>输入:</strong>s = &quot;TO BE OR NOT TO BE&quot;
<strong>输出:</strong>[&quot;TBONTB&quot;,&quot;OEROOE&quot;,&quot; T&quot;]
<strong>解释:</strong>题目允许使用空格补位,但不允许输出末尾出现空格。
&quot;TBONTB&quot;
&quot;OEROOE&quot;
&quot; T&quot;
</pre>
<p><strong>示例 3</strong></p>
<pre><strong>输入:</strong>s = &quot;CONTEST IS COMING&quot;
<strong>输出:</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>提示:</strong></p>
<ul>
<li><code>1 &lt;= s.length &lt;= 200</code></li>
<li><code>s</code>&nbsp;仅含大写英文字母。</li>
<li>题目数据保证两个单词之间只有一个空格。</li>
</ul>