X650: referenceSecondLastNode

Consider the following class definition:
   class Link{
      Object data;
      Link next;
   }
Return a reference to the second to last node (null if list is empty or only contains one node). Given a list L [1,2,3,4], your solution should return a reference to [3, 4].

Initial Setup Final Configuration

Your Answer:

x
 
1
public static Link refSecondLastNode(Link p)
2
{
3
    
4
    return p;
5
}
6
Reset
Visualize

Feedback

Your feedback will appear here when you check your answer.