/** * struct ListNode { * int val; * struct ListNode *next; * ListNode(int x) : val(x), next(nullptr) {} * }; */ class Solution { public: ListNode* reverseBetween(ListNode* head, int m, int n) { if (m == n || head == nullptr) { //如果链表为空,或者交换同一个节点 return head; } ListNode* reversedHead, *reversedEnd; ...