# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def reverseList(self, head: Optional[ListNode]) -> Optional[ListNode]:
if not head :
return head
pre =None
cur =head
while cur :
temp =cur.next
cur.next=pre
pre =cur
cur =temp
return pre
206. 反转链表
最新推荐文章于 2025-11-30 23:27:53 发布
832

被折叠的 条评论
为什么被折叠?



