01 · Question
Reverse an array of characters in place using O(1) extra memory. Modify the existing array; do not return a new one.
Examples: [h,e,l,l,o] → [o,l,l,e,h]; [] → []; [a] → [a]. The Go snippets operate on ASCII bytes, matching the exercise's character constraints.
02 · Analysis
Swap the leftmost and rightmost remaining characters, then move inward. Stop when left≥right. The outside portion is already in its final position.
Iteration meets the requirement: O(n) time and O(1) auxiliary space. Recursion is a comparison only: it also mutates in place, but needs about n/2 active frames, hence O(n) auxiliary space. It does not meet the O(1)-space requirement and may exceed runtime depth limits. Both versions below produce the same mutations.
03 · Solution