Reverse Linked List

描述

Reverse a singly linked list.

分析

用三个指针 tail,p,q,紧紧相邻,不断前进,每次将p.next指向tail,将q.next指向p

解法1 迭代

解法2 递归

results matching ""

    No results matching ""