mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-13 19:31:42 +08:00
add leetcode problem-cn part3
This commit is contained in:
39
算法题(国内版)/problem (Chinese)/山羊拉丁文 [goat-latin].html
Normal file
39
算法题(国内版)/problem (Chinese)/山羊拉丁文 [goat-latin].html
Normal file
@@ -0,0 +1,39 @@
|
||||
<p>给定一个由空格分割单词的句子 <code>S</code>。每个单词只包含大写或小写字母。</p>
|
||||
|
||||
<p>我们要将句子转换为 <em>“Goat Latin”</em>(一种类似于 猪拉丁文 - Pig Latin 的虚构语言)。</p>
|
||||
|
||||
<p>山羊拉丁文的规则如下:</p>
|
||||
|
||||
<ul>
|
||||
<li>如果单词以元音开头(a, e, i, o, u),在单词后添加<code>"ma"</code>。<br />
|
||||
例如,单词<code>"apple"</code>变为<code>"applema"</code>。</li>
|
||||
<br />
|
||||
<li>如果单词以辅音字母开头(即非元音字母),移除第一个字符并将它放到末尾,之后再添加<code>"ma"</code>。<br />
|
||||
例如,单词<code>"goat"</code>变为<code>"oatgma"</code>。</li>
|
||||
<br />
|
||||
<li>根据单词在句子中的索引,在单词最后添加与索引相同数量的字母<code>'a'</code>,索引从1开始。<br />
|
||||
例如,在第一个单词后添加<code>"a"</code>,在第二个单词后添加<code>"aa"</code>,以此类推。</li>
|
||||
</ul>
|
||||
|
||||
<p>返回将 <code>S</code> 转换为山羊拉丁文后的句子。</p>
|
||||
|
||||
<p><strong>示例 1:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>输入: </strong>"I speak Goat Latin"
|
||||
<strong>输出: </strong>"Imaa peaksmaaa oatGmaaaa atinLmaaaaa"
|
||||
</pre>
|
||||
|
||||
<p><strong>示例 2:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>输入: </strong>"The quick brown fox jumped over the lazy dog"
|
||||
<strong>输出: </strong>"heTmaa uickqmaaa rownbmaaaa oxfmaaaaa umpedjmaaaaaa overmaaaaaaa hetmaaaaaaaa azylmaaaaaaaaa ogdmaaaaaaaaaa"
|
||||
</pre>
|
||||
|
||||
<p><strong>说明:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>S</code> 中仅包含大小写字母和空格。单词间有且仅有一个空格。</li>
|
||||
<li><code>1 <= S.length <= 150</code>。</li>
|
||||
</ul>
|
Reference in New Issue
Block a user