You are given a string of N characters(1-indexed), and an integer D. Now you select the substring S[1]…S[D] and swap the letters in the following manner:
S[1],S[2]…S[D-1]S[D] => S[D]S[D-1]S[D-2]…S[2]S[1]
Next you select the substring S[2]…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.