Question 1: Write a Python program Given a string s and an integer array indicesof the same
Fantastic news! We've Found the answer you've been seeking!
Question:
Question 1: Write a Python program
Given a string s and an integer array indicesof the same length.
The string s will be shuffled such that the character at the ithposition moves to indices[i] in the shuffled string. Return theshuffled string.
Sample Output:
Input: s = "codeleet", indices = [4,5,6,7,0,2,1,3]
Output: "leetcode"
Explanation: As shown, "codeleet" becomes "leetcode" aftershuffling.
or:
Input : string = “nuectyr”, indices = [2,4,1,0,3,6,5]
Output: century
Explanation: As shown, "nuectyr" becomes "century" aftershuffling.
Related Book For
Introduction to Algorithms
ISBN: 978-0262033848
3rd edition
Authors: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest
Posted Date: