Loading

摘要: class Solution: def subarraySum(self, nums: List[int], k: int) -> int: map = {0: 1} cur_sum = 0 counter = 0 for i in nums: cur_sum += i counter += map 阅读全文
posted @ 2024-09-10 23:31 Duancf 阅读(26) 评论(0) 推荐(0)
摘要: 线程安全的List 目前比较常用的构建线程安全的List有三种方法: 使用Vector容器 使用Collections的静态方法synchronizedList(List< T> list) 采用CopyOnWriteArrayList容器 使用Vector容器 Vector类实现了可扩展的对象数组 阅读全文
posted @ 2024-09-10 21:21 Duancf 阅读(2344) 评论(0) 推荐(0)
摘要: https://www.codedump.info/post/20220807-weekly-23/#概论 阅读全文
posted @ 2024-09-10 20:28 Duancf 阅读(17) 评论(0) 推荐(0)
摘要: 1.一致性定义 关于一致性的定义,大概如下: 一致性(Consistency)是指多副本(Replications)问题中的数据一致性。可以分为强一致性、顺序一致性与弱一致性。 1.1 强一致性(Strict Consistency) 强一致性也被可以被称做: 原子一致性(Atomic Consis 阅读全文
posted @ 2024-09-10 20:01 Duancf 阅读(171) 评论(0) 推荐(0)
摘要: class Solution: def spiralOrder(self, matrix: List[List[int]]) -> List[int]: res = [] left = 0 right = len(matrix[0]) - 1 down = len(matrix) - 1 up = 阅读全文
posted @ 2024-09-10 16:15 Duancf 阅读(18) 评论(0) 推荐(0)
摘要: class Solution: def sortArray(self, nums: List[int]) -> List[int]: def quicksort(nums): if not nums: return [] pivot = random.choice(nums) less = [] e 阅读全文
posted @ 2024-09-10 16:14 Duancf 阅读(21) 评论(0) 推荐(0)
摘要: 为什么主键索引最好是有序递增的 移动元素。如果主键不是有序递增的,比如一个叶子结点的存储范围是1-10现在已经存储了2-9,现在我们想要插入数据1就必须要把2-9的数据向后移动。 更多的IO。如果主键不是有序递增的,我们可能需要经常访问那些很久之前访问过的节点,甚至是已经被刷回磁盘的页,这样会造成很 阅读全文
posted @ 2024-09-10 13:49 Duancf 阅读(238) 评论(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 @ 2024-09-10 11:45 Duancf 阅读(18) 评论(0) 推荐(0)
摘要: class Solution: def maxSlidingWindow(self, nums: List[int], k: int) -> List[int]: n = len(nums) res = [] queue = [[0,nums[0]]] for i in range(1,k): wh 阅读全文
posted @ 2024-09-10 11:16 Duancf 阅读(28) 评论(0) 推荐(0)