ListNode* reverseList(ListNode* head) {
ListNode* tail = nullptr;
return reverseRecursive(head, tail);
ListNode* reverseRecursive(ListNode *head, ListNode *&tail) {
if (head->next == nullptr) {
auto h = reverseRecursive(head->next, tail);
ListNode* reverseList(ListNode* head) {
if (head == nullptr) return head;
return reverseRecursive(nullptr, head, head->next);
ListNode* reverseRecursive(ListNode *prev, ListNode *head, ListNode *next)
if (next == nullptr) return head;
return reverseRecursive(head, next, n);