应用题-链表专题-反转链表
```python
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
# 示例: 输入: 1->2->3->4->5->NULL 输出: 5->4->3->2->1->NULL
def reverseList(self, head: Optional[ListNode]) -> Optional[ListNode]:
if not head: return None
if head and not head.next: return head
prv = None
cur = head
while cur:
t = cur.next
cur.next = prv
prv = cur
cur = t
return prv
```