mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-11 02:58:13 +08:00
42 lines
1.5 KiB
HTML
42 lines
1.5 KiB
HTML
<p>给你一个字符串 <code>s</code>。请你按照单词在 <code>s</code> 中的出现顺序将它们全部竖直返回。<br>
|
||
单词应该以字符串列表的形式返回,必要时用空格补位,但输出尾部的空格需要删除(不允许尾随空格)。<br>
|
||
每个单词只能放在一列上,每一列中也只能有一个单词。</p>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>示例 1:</strong></p>
|
||
|
||
<pre><strong>输入:</strong>s = "HOW ARE YOU"
|
||
<strong>输出:</strong>["HAY","ORO","WEU"]
|
||
<strong>解释:</strong>每个单词都应该竖直打印。
|
||
"HAY"
|
||
"ORO"
|
||
"WEU"
|
||
</pre>
|
||
|
||
<p><strong>示例 2:</strong></p>
|
||
|
||
<pre><strong>输入:</strong>s = "TO BE OR NOT TO BE"
|
||
<strong>输出:</strong>["TBONTB","OEROOE"," T"]
|
||
<strong>解释:</strong>题目允许使用空格补位,但不允许输出末尾出现空格。
|
||
"TBONTB"
|
||
"OEROOE"
|
||
" T"
|
||
</pre>
|
||
|
||
<p><strong>示例 3:</strong></p>
|
||
|
||
<pre><strong>输入:</strong>s = "CONTEST IS COMING"
|
||
<strong>输出:</strong>["CIC","OSO","N M","T I","E N","S G","T"]
|
||
</pre>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>提示:</strong></p>
|
||
|
||
<ul>
|
||
<li><code>1 <= s.length <= 200</code></li>
|
||
<li><code>s</code> 仅含大写英文字母。</li>
|
||
<li>题目数据保证两个单词之间只有一个空格。</li>
|
||
</ul>
|