Question d’entretien chez Microsoft

Reverse a double linked list

Réponse à la question d'entretien

Utilisateur anonyme

23 sept. 2021

swap previous and next pointers for all nodes, change previous of the head (or start) and change the head pointer in the end. // swapping pointer let reverseDLL = (head) => { let temp = null; let current = head; while(current){ temp = current.prev; current.prev = current.next; current.next = temp; current = current.prev; } if (temp != null) { head = temp.prev; } }