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 (Chinese)/找出加密后的字符串 [find-the-encrypted-string].html
2024-07-16 16:03:30 +08:00

49 lines
1.6 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>给你一个字符串 <code>s</code> 和一个整数 <code>k</code>。请你使用以下算法加密字符串:</p>
<ul>
<li>对于字符串 <code>s</code> 中的每个字符 <code>c</code>,用字符串中 <code>c</code> 后面的第 <code>k</code> 个字符替换 <code>c</code>(以循环方式)。</li>
</ul>
<p>返回加密后的字符串。</p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">s = "dart", k = 3</span></p>
<p><strong>输出:</strong> <span class="example-io">"tdar"</span></p>
<p><strong>解释:</strong></p>
<ul>
<li>对于 <code>i = 0</code><code>'d'</code> 后面的第 3 个字符是 <code>'t'</code></li>
<li>对于 <code>i = 1</code><code>'a'</code> 后面的第 3 个字符是 <code>'d'</code></li>
<li>对于 <code>i = 2</code><code>'r'</code> 后面的第 3 个字符是 <code>'a'</code></li>
<li>对于 <code>i = 3</code><code>'t'</code> 后面的第 3 个字符是 <code>'r'</code></li>
</ul>
</div>
<p><strong class="example">示例 2</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">s = "aaa", k = 1</span></p>
<p><strong>输出:</strong> <span class="example-io">"aaa"</span></p>
<p><strong>解释:</strong></p>
<p>由于所有字符都相同,加密后的字符串也将相同。</p>
</div>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= s.length &lt;= 100</code></li>
<li><code>1 &lt;= k &lt;= 10<sup>4</sup></code></li>
<li><code>s</code> 仅由小写英文字母组成。</li>
</ul>