206. Reverse Linked List

Input: 1->2->3->4->5->NULL
Output: 5->4->3->2->1->NULL

iterative version

  1. try to think about making 1 -> NULL

  2. 1->2->3->4->5->NULL becomes NULL<-1 2->3->4->5->NULL

Last updated

Was this helpful?