摘要:
class Solution: def isPalindrome(self, head: ListNode) -> bool: vals = [] current_node = head while current_node is not None: vals.append(current_node 阅读全文
摘要:
class Solution: def reverseList(self, head: ListNode) -> ListNode: #空链表 if not head: return None #1节点链表 elif not head.next: return head #多节点链表 else: p 阅读全文
摘要:
class Solution: def getIntersectionNode(self, headA: ListNode, headB: ListNode) -> ListNode: a, b = headA, headB while a != b: if a: a = a.next else: 阅读全文
摘要:
class Solution: # 归并排序 def sortList(self, head: ListNode) -> ListNode: if not head or not head.next: return head left_end = self.find_mid(head) mid = 阅读全文
摘要:
解题思路 1、快慢指针找中点,等分成左右两个部分2、右半部分逆序3、左右两个部分逐个拼接 class Solution: def reorderList(self, head: ListNode) -> None: """ Do not return anything, modify head in 阅读全文