2dbi
Home/Tesla/Reverse Linked List
TTesla·DSASDE-1Online Assessment

Reverse Linked List

Problem

Reverse a singly linked list and return the new head.

Example

1->2->3->4->5  =>  5->4->3->2->1

Constraints

  • 0 ≤ nodes ≤ 5000

Follow-up

Do it both iteratively and recursively; discuss the space difference.

added 6 days ago
LeadersAccount