You are given a string of N characters(1-indexed), and an integer D. Now you select the substring S…S[D] and swap the letters in the following manner:
S,S…S[D-1]S[D] => S[D]S[D-1]S[D-2]…SS
Next you select the substring S…S[D+1] and do the same. You do this operation likewise N-D+1 times, shifting the substring by 1 position to the right for every consecutive operation. (selecting substring S[N-D+1]…S[N] in the last step.
Find the string at the end. O(NlogN)
I am not sure if this is a very standard problem or not. Opinions welcomed.