Question d’entretien chez Apple

Reverse a singly linked list

Réponse à la question d'entretien

Utilisateur anonyme

6 juin 2026

class Solution { public: ListNode* reverseList(ListNode* head) { if (head == nullptr || head->next == nullptr) return head; ListNode* newHead = reverseList(head->next); head->next->next = head; head->next = nullptr; return newHead; } };