Skip to content
This repository has been archived by the owner on Jul 30, 2020. It is now read-only.

Latest commit

 

History

History
executable file
·
23 lines (12 loc) · 722 Bytes

Reverse_Linked_List.md

File metadata and controls

executable file
·
23 lines (12 loc) · 722 Bytes

Reverse Linked List

Problem Statement

Write a function that takes in the head of a Singly Linked List (assume that the list has at least 1 node; in other words, the head will never be a null value). The function should reverse the list and return its new head. Note that every node in the Singly Linked List has a "value" property storing its value as well as a "next" property pointing to the next node in the list or None (null) if it is the tail of the list.

Sample input: 0 -> 1 -> 2 -> 3 -> 4 -> 5 (the head node with value 0) Sample output: 5 -> 4 -> 3 -> 2 -> 1 -> 0 (the new head node with value 5)

Explanation

Solution

Check this Python code.