chars. Put its elements in reverse order: the first character must end up last, the second one second to last, and so on.
Return the flipped chars.
Try to use only O(1) extra memory.chars=['r', 'a', 'd', 'a', 'r', 's'] → ['s', 'r', 'a', 'd', 'a', 'r']
After the flip the list is ['s', 'r', 'a', 'd', 'a', 'r'].
chars=['Q', '?'] → ['?', 'Q']
The two characters just swap: ['?', 'Q'].
chars=['z'] → ['z']
A single character has nowhere to go, so the list stays the same.
chars.length ≤ 10⁵chars[i] is a printable ASCII characterchars=['r', 'a', 'd', 'a', 'r', 's']
['s', 'r', 'a', 'd', 'a', 'r']
Run checks the first 3 tests in your browser. Submit checks all 35 tests on the server, hidden ones included.