Reverse a Linked List

Easy · Linked Lists · about 10 minutes

Asked at Amazon, Microsoft, Apple, Meta, Sony.

Flip the direction of a singly linked list so that the old tail becomes the first node, and return that node. Write it iteratively, and be ready to describe how a recursive version would work.