重新排列字符串
2025-4-20
| 2025-4-20
Words 297Read Time 1 min
type
status
date
slug
summary
tags
category
icon
password

题目:

给你一个字符串 s 和一个 长度相同 的整数数组 indices
请你重新排列字符串 s ,其中第 i 个字符需要移动到 indices[i] 指示的位置。
返回重新排列后的字符串。
来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/SNJvJP 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。
示例 1:
notion image
q1
示例 2:
提示:
  • s.length == indices.length == n
  • 1 <= n <= 100
  • s 仅包含小写英文字母
  • 0 <= indices[i] < n
  • indices 的所有的值都是 唯一

思路:

  • 创建一个字符串数组,把字符放到对应的位置,再把字符串数组转换为字符串

代码:

结果:

notion image
image-20220412104504625
长度和颜色单位重复的子字符串
Loading...