Write a method that takes in a string and an array of indices in the string. Produce a new string, which contains letters from the input string in the order specified by the indices of the array of indices.
Note the lack of ‘if’ statement and how idx is incremented inside the while loop.
Second time solving this:
It helps to write out the new string positions beforehand.
Third time doing this, I got a bit too creative but it worked: