electroRF
Member
Hi,
I ran into the following question that was asked in an interview and I really hope to be able to answer it correctly.
The question is not that clear - but i write it here word for word:
- Given a singly-linked list.
- there's a program in which the next node to be looked is in + or - K steps from the previous found Node.
- Write that program which finds the next node in the fastet run time.
I believe that the program receives the previous node that was found, and a number K (which can be positive or negative), and it needs to find the next Node which is K steps from the previous node.
I don't manage to find a solution which is less then O(K).
Do you have an idea?
Thank you very much.
I ran into the following question that was asked in an interview and I really hope to be able to answer it correctly.
The question is not that clear - but i write it here word for word:
- Given a singly-linked list.
- there's a program in which the next node to be looked is in + or - K steps from the previous found Node.
- Write that program which finds the next node in the fastet run time.
I believe that the program receives the previous node that was found, and a number K (which can be positive or negative), and it needs to find the next Node which is K steps from the previous node.
I don't manage to find a solution which is less then O(K).
Do you have an idea?
Thank you very much.