mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
38 lines
1.3 KiB
HTML
38 lines
1.3 KiB
HTML
<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> </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> </p>
|
||
|
||
<p><strong>提示:</strong></p>
|
||
|
||
<ul>
|
||
<li><code>s.length == indices.length == n</code></li>
|
||
<li><code>1 <= n <= 100</code></li>
|
||
<li><code>s</code> 仅包含小写英文字母</li>
|
||
<li><code>0 <= indices[i] < n</code></li>
|
||
<li><code>indices</code> 的所有的值都是 <strong>唯一</strong> 的</li>
|
||
</ul>
|