American Express Interview Question

Locate the middle node in a single-linked list with one pass through the data.

Interview Answer

Anonymous

Jan 27, 2015

have 2 references x,y; advance x by 1, but y by 2 nodes. when y hits the end of list x is the middle.

2