Your question is In-Place String Reversal. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Implement two in-place operations without using additional memory allocation: reverse a string represented as a mutable character array, and swap two integers without using a temporary variable.
Write a function that performs one of the following based on the input mode:
mode == "reverse": reverse the list of single-character strings in place.mode == "swap": swap two integers and return the swapped pair.mode, a string equal to "reverse" or "swap"mode == "reverse", data is a list of single-character stringsmode == "swap", data is a list of exactly two integersmode == "reverse", return the modified character listmode == "swap", return the swapped two-element listdef in_place_reverse_or_swap(mode, data):