Simply Hired Interview Question: Find common node of two singl... | Glassdoor

Interview Question

Junior Software Engineer Interview Mountain View, CA

Find common node of two singly linked list given the heads

  of two nodes.
Answer

Interview Answer

1 Answer

0

find the length of two LL. Move the pointer in longer LL by difference(say if L1 - L2 = 3 then move pointer of L1 3 times once) for the 1st time and then increment each pointer one by one.

Interview Candidate on Dec 5, 2011

Add Answers or Comments

To comment on this, Sign In or Sign Up.