mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-13 19:31:42 +08:00
add leetcode problem-cn part5
This commit is contained in:
32
算法题(国内版)/problem (Chinese)/反转字符串 II [reverse-string-ii].html
Normal file
32
算法题(国内版)/problem (Chinese)/反转字符串 II [reverse-string-ii].html
Normal file
@@ -0,0 +1,32 @@
|
||||
<p>给定一个字符串 <code>s</code> 和一个整数 <code>k</code>,从字符串开头算起,每计数至 <code>2k</code> 个字符,就反转这 <code>2k</code> 字符中的前 <code>k</code> 个字符。</p>
|
||||
|
||||
<ul>
|
||||
<li>如果剩余字符少于 <code>k</code> 个,则将剩余字符全部反转。</li>
|
||||
<li>如果剩余字符小于 <code>2k</code> 但大于或等于 <code>k</code> 个,则反转前 <code>k</code> 个字符,其余字符保持原样。</li>
|
||||
</ul>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>示例 1:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>输入:</strong>s = "abcdefg", k = 2
|
||||
<strong>输出:</strong>"bacdfeg"
|
||||
</pre>
|
||||
|
||||
<p><strong>示例 2:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>输入:</strong>s = "abcd", k = 2
|
||||
<strong>输出:</strong>"bacd"
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>提示:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>1 <= s.length <= 10<sup>4</sup></code></li>
|
||||
<li><code>s</code> 仅由小写英文组成</li>
|
||||
<li><code>1 <= k <= 10<sup>4</sup></code></li>
|
||||
</ul>
|
Reference in New Issue
Block a user