Pergunta de entrevista da empresa OfferUp

Given two linked lists, find the node at which they merge.

Resposta da entrevista

Sigiloso

15 de set. de 2016

int FindMergeNode(Node headA, Node headB) { Node curA = headA; Node curB = headB; while (curA!=curB){ if (curA.next==null){ curA = headB; } else { curA = curA.next; } if (curB.next==null){ curB = headA; } else{ curB = curB.next; } } return curA.data; }

2