X360: insertListAfterRef13

Consider the following class definition:
   class Link{
      Object data;
      Link next;
   }
p is a reference to the first node of list L. Integer val is the value of a node in L. Link q is a reference to a list that you would append after the node containing val (if there was one). If q or val are null or don’t exist, then p should remain unchanged. Return list p with the addition of q.

Initial Setup Final Configuration

Examples:

insertListAfterRef(Link.CreateList(1,2,3),1,Link.CreateList(5,6,7,8)) -> Link.CreateList(1,5,6,7,8,2,3)
Reset
Visualize

Practice a different Java exercise