X347: firstNodeEqualsValue

Consider the following class definition:
   class Link{
      Object data;
      Link next;
List L has a reference p to the first node. Write code that returns a reference to the node before the first node in the chain that equals to a given parameter (otherwise return null) - could do this with a look ahead or runner technique. Make sure to account for edge cases!

Initial Setup Final Configuration


refFirstNodeWithValue(Link.CreateList(4,3,2),3) -> Link.CreateList(4,3,2)

Your Answer:


Practice a different Java exercise


Your feedback will appear here when you check your answer.