Pergunta de entrevista da empresa Microsoft

Reverse a double linked list

Resposta da entrevista

Sigiloso

23 de set. de 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; } }