Challenge: Reverse a Linked List

Can you reverse a linked list given as an input to your function? A solution is placed in the "solution" section for your help, but we would suggest you solve it on your own first.

Problem Statement #

In this problem, you have to implement the public static <T> void reverse(SinglyLinkedList<T> list) method, which will take a linked list as input and reverse its content. An illustration is also provided for your help to see how the linked list will look after passing it to your function.

Method Prototype: #

public static <T> void reverse(SinglyLinkedList<T> list)

Output: #

A Singly linked list with all its content stored in reverse order.

Sample Input #

linkedlist = 10->9->4->4-6

Sample Output #

linkedlist = 6->4->4->9->10

Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy