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)/重新排列字符串 [shuffle-string].html
2022-03-29 12:43:11 +08:00

38 lines
1.3 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> 和一个 <strong>长度相同</strong> 的整数数组 <code>indices</code></p>
<p>请你重新排列字符串 <code>s</code> ,其中第 <code>i</code> 个字符需要移动到 <code>indices[i]</code> 指示的位置。</p>
<p>返回重新排列后的字符串。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<p><img alt="" src="https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2020/07/26/q1.jpg" /></p>
<pre>
<strong>输入:</strong>s = "codeleet", <code>indices</code> = [4,5,6,7,0,2,1,3]
<strong>输出:</strong>"leetcode"
<strong>解释:</strong>如图所示,"codeleet" 重新排列后变为 "leetcode" 。
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>s = "abc", <code>indices</code> = [0,1,2]
<strong>输出:</strong>"abc"
<strong>解释:</strong>重新排列后,每个字符都还留在原来的位置上。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>s.length == indices.length == n</code></li>
<li><code>1 &lt;= n &lt;= 100</code></li>
<li><code>s</code> 仅包含小写英文字母</li>
<li><code>0 &lt;= indices[i] &lt;&nbsp;n</code></li>
<li><code>indices</code> 的所有的值都是 <strong>唯一</strong></li>
</ul>