
You are given a string S which may contain one or more words separated by spaces. Your task is to transform this string based on a specific set of rules.
The transformation process is as follows:
Split: The input string S is first split into parts (words) based on spaces.
Rearrange: For each part, you will create a new string by first taking all characters at even indices (0, 2, 4, ...) in the order they appear, and then appending all characters at odd indices (1, 3, 5, ...) in the order they appear.
Combine: The transformed parts are then joined back together with a single space between them to form the final output string.
The first and only line of input contains a single string S.
The function should return the final transformed string.
If the input string contains no spaces, it is treated as a single part.
If there are multiple spaces between words, they should be treated as a single space delimiter when joining the final parts.
Python's string slicing (string[start:stop:step]) is particularly useful for this task.
Hello World
Hloel Wrdol
Part 1: "Hello"
Even-indexed characters: 'H', 'l', 'o' -> "Hlo"
Odd-indexed characters: 'e', 'l' -> "el"
Combined part: "Hloel"
Part 2: "World"
Even-indexed characters: 'W', 'r', 'd' -> "Wrd"
Odd-indexed characters: 'o', 'l' -> "ol"
Combined part: "Wrdol"
Final Result: "Hloel Wrdol"
Vaibhav
Vihvaba
The string is treated as a single part: "Vaibhav".
Even-indexed characters: 'V', 'i', 'h', 'v' -> "Vihv"
Odd-indexed characters: 'a', 'b', 'a' -> "aba"
Combined result: "Vihvaba"
The expected time complexity is O(N).
1 <= length of S <= 10^5
The string S can contain any standard ASCII characters.
Time limit: 1 sec