Implement solve(arr) that:
1. Builds a singly-linked list from arr.
2. Reverses the list in-place.
3. Returns the values as a plain array.
A node has { val, next }. Return [] for an empty input.
Example: solve([1,2,3,4,5]) → [5,4,3,2,1]
Sample tests