Coding Task: Reverse a List In-Place (Python)
Context
You're implementing a utility function during a technical screen. The function must reverse a Python list in-place without allocating another list.
Requirements
-
Implement a function that reverses a Python list in-place.
-
Constraints:
-
No slicing (e.g., arr[::-1]), no list(), and no reversed().
-
Time complexity: O(n).
-
Extra space: O(1).
-
Must work for empty lists, and for odd/even-length lists.
-
Deliverables:
-
The function implementation.
-
Brief correctness reasoning.
-
Time and space complexity.
-
Tests that demonstrate in-place behavior (e.g., object id unchanged) and cover edge cases like [], [1], and [1, 4, 8, 12, 16, 20] → [20, 16, 12, 8, 4, 1].