上一页 1 ··· 210 211 212 213 214 215 216 217 218 ··· 385 下一页
摘要: 阅读全文
posted @ 2021-09-17 21:44 秋华 阅读(44) 评论(0) 推荐(0)
该文被密码保护。 阅读全文
posted @ 2021-09-17 00:12 秋华 阅读(0) 评论(0) 推荐(0)
摘要: class Solution: def isPalindrome(self, head: ListNode) -> bool: vals = [] current_node = head while current_node is not None: vals.append(current_node 阅读全文
posted @ 2021-09-12 20:19 秋华 阅读(38) 评论(0) 推荐(0)
摘要: class Solution: def reverseList(self, head: ListNode) -> ListNode: #空链表 if not head: return None #1节点链表 elif not head.next: return head #多节点链表 else: p 阅读全文
posted @ 2021-09-12 20:15 秋华 阅读(42) 评论(0) 推荐(0)
摘要: # Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def 阅读全文
posted @ 2021-09-12 20:09 秋华 阅读(52) 评论(0) 推荐(0)
摘要: class Solution: def getIntersectionNode(self, headA: ListNode, headB: ListNode) -> ListNode: a, b = headA, headB while a != b: if a: a = a.next else: 阅读全文
posted @ 2021-09-12 20:06 秋华 阅读(118) 评论(0) 推荐(0)
摘要: class Solution: # 归并排序 def sortList(self, head: ListNode) -> ListNode: if not head or not head.next: return head left_end = self.find_mid(head) mid = 阅读全文
posted @ 2021-09-12 20:02 秋华 阅读(59) 评论(0) 推荐(0)
摘要: 解题思路思路的话就是打牌呗,看到后面比前面大的,在前面一个一个找,找到了就记录下一张牌,然后当前牌放到前面去,前面的pre放到后面去,结束这一次循环。提前用dummy记录,然后利用pre对dummy第一层的操作可以让dummy一直指向最前面的牌 class Solution: def inserti 阅读全文
posted @ 2021-09-12 19:59 秋华 阅读(59) 评论(0) 推荐(0)
摘要: 1.调库太难了,一些用法比较生僻。不如手写 2.可能面试时候,就是想让手写 3.小建议:(1)head 和 tail是dummy结点。一定要用,不然光check边界就会疯掉(2)类中的函数不是固定的。根据自己的习惯和设计,需要什么功能就写什么功能(3)双向链表中的尽量‘干净’、‘简洁’。本来就是很容 阅读全文
posted @ 2021-09-12 19:58 秋华 阅读(65) 评论(0) 推荐(0)
摘要: 解题思路 1、快慢指针找中点,等分成左右两个部分2、右半部分逆序3、左右两个部分逐个拼接 class Solution: def reorderList(self, head: ListNode) -> None: """ Do not return anything, modify head in 阅读全文
posted @ 2021-09-12 19:55 秋华 阅读(120) 评论(0) 推荐(0)
上一页 1 ··· 210 211 212 213 214 215 216 217 218 ··· 385 下一页