摘要: 自己写的,遍历一遍链表,再反向生成一个新链表 class Solution: def reverseList(self, head: Optional[ListNode]) -> Optional[ListNode]: # 检查链表是否为空 if not head: return None # 初始 阅读全文
posted @ 2024-03-11 10:16 Junior_bond 阅读(5) 评论(0) 推荐(0)