随笔分类 - 剑指offer
摘要:1 # -*- coding:utf-8 -*- 2 """用row和col两参数逐行或逐列遍历数组""" 3 class Solution: 4 # array 二维列表 5 def Find(self, target, array): 6 # write code here 7 rows = l
阅读全文
摘要:1 # -*- coding:utf-8 -*- 2 # class ListNode: 3 # def __init__(self, x): 4 # self.val = x 5 # self.next = None 6 """没有三个指针解决不了的问题""" 7 class Solution:
阅读全文
摘要:1 # -*- coding:utf-8 -*- 2 # class ListNode: 3 # def __init__(self, x): 4 # self.val = x 5 # self.next = None 6 class Solution: 7 def EntryNodeOfLoop(
阅读全文
摘要:1 # -*- coding:utf-8 -*- 2 # class ListNode: 3 # def __init__(self, x): 4 # self.val = x 5 # self.next = None 6 """首先判断长度,然后移动指针将两个链表尾部对齐,当两链表的头指针相等时,
阅读全文
摘要:1 # -*- coding:utf-8 -*- 2 # class ListNode: 3 # def __init__(self, x): 4 # self.val = x 5 # self.next = None 6 class Solution: 7 # 返回合并后列表 8 def Merg
阅读全文
摘要:1 # -*- coding:utf-8 -*- 2 # class ListNode: 3 # def __init__(self, x): 4 # self.val = x 5 # self.next = None 6 """pHead指针通过其.next属性将原链表上next_指针前移,pre
阅读全文
摘要:1 # -*- coding:utf-8 -*- 2 # class ListNode: 3 # def __init__(self, x): 4 # self.val = x 5 # self.next = None 6 7 """双指针的关键是如何保持指针的距离为k-1""" 8 class S
阅读全文
摘要:1 # -*- coding:utf-8 -*- 2 # class ListNode: #指的是每一个点的数值 3 # def __init__(self, x): 4 # self.val = x 5 # self.next = None 6 7 class Solution: 8 # 返回从尾
阅读全文