Coding Challenge

Reverse Linked List

Easy
linked-list

Reverse a singly linked list.

Given the head of a singly linked list, reverse the list and return the new head.

Examples

Input: head = [1,2,3,4,5]

Output: [5,4,3,2,1]

Constraints

  • List may be empty

Preparing your coding workspace...