#K6336. Restore String
Restore String
Restore String
Given a string s
and an array of indices, your task is to reorder the string by placing each character s[i]
at the position specified by indices[i]
. The input guarantees that the indices form a permutation of the positions in the string.
For example, given s = "codeleet"
and indices = [4,5,6,7,0,2,1,3]
, the restored string is leetcode
because:
- The character
'c'
from index 0 goes to index 4. - The character
'o'
from index 1 goes to index 5. - … and so on.
Note: If any mathematical formula is required, use the LaTeX format. In this problem, however, no complex formula is needed.
inputFormat
The input is read from standard input (stdin) and consists of two lines. The first line contains the string s
. The second line contains the space-separated integer values representing the indices
array.
outputFormat
Output the restored string on standard output (stdout).## sample
codeleet
4 5 6 7 0 2 1 3
leetcode