
You are given a string s that contains words separated by one or more spaces. Your task is to perform a "mirrored reversal" on the string.
A mirrored reversal consists of two steps:
1) Reverse the order of the words in the string.Crucially, the original pattern of whitespace (the number of spaces between words, and any leading/trailing spaces) must be preserved and redistributed between the newly ordered words.
A single line containing the string s.
Print the modified string on a single line.
hi myself john
nhoj flesym ih
1. The words are `["hi", "myself", "john"]`.
2. The separators are `[" ", " "]`.
3. Reverse the order of words: `["john", "myself", "hi"]`.
4. Reverse the characters in each word: `["nhoj", "flesym", "ih"]`.
5. Reconstruct the string with the original separators: `nhoj` + ` ` + `flesym` + ` ` + `ih`.
a b c
c b a
1. Words: `["a", "b", "c"]`. Separators: `[" ", " ", " "]` (leading, between, trailing).
2. Reverse words: `["c", "b", "a"]`.
3. Reverse characters: `["c", "b", "a"]`.
4. Reconstruct: ` ` + `c` + ` ` + `b` + ` ` + `a`.
The expected time complexity is O(N), where N is the length of the string.