Reverse a string while preserving the spaces.
Given a string s, reverse the order of all non-space characters while keeping each literal space character (' ') at its original index. Return the resulting string.
Function: def reverse_string(s):
Input: A string s.
Output: A string with non-space characters reversed and spaces unchanged.
Examples: "ab cd" becomes "dc ba"; "a b" becomes "b a".
Constraints: 0 <= len(s) <= 10^4; the input contains printable characters and spaces.
' ' is preserved speciallydef reverse_string(s):