April 19th, 2014, 06:57 AM
Finding the common node of 2 linked lists, without checking the length
Hello, first of all i have seen the answer about this before, but it is a little bit diffrent.
i will quote the exact question i have been given:
You have 2 linked lists, l1 and l2, which merge into 1 list on a certain node, find that node.
but it must be with O(n+m), when n and m are the length of the 2 lists, Untill the shared node.
You may use additional O(1) extra memory.
now i know how to find the common link, when n and m are the total length of the lists, but given the fact that i can only reach to the first common node, i cant find a possible solution, ofc you cant put flags or change the lists.
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!