You are given the head pointer of a singly linked list. Write a function that reverses the entire list in-place and returns a pointer to the new head. You may only use the head pointer that is passed to you—no dummy nodes, no extra lists, and no recursion stacks that grow with n. All node objects already exist; you must relink them, not create or destroy any nodes. The algorithm must run in O(n) time and O(1) additional space.

视频信息