摘要: from typing import List# 方法:使用并查集的想法,有个人那就是有两个组合,然后挨着判断# 每个人的节点是否相连,是否相连后还有多余的连线。# 定义一个并查集类,稍微改变了一下。class UnionFind: def __init__(self,size): self.fat 阅读全文
posted @ 2021-01-28 19:32 月为暮 阅读(50) 评论(0) 推荐(0) 编辑
摘要: from typing import Listclass Solution: # 错误的想法,刚开始想的是使用双指针的方法来计算左右两边的和, # 但是没有考虑到会有负数的存在,所有这个方法,行不通。 def pivotIndex1(self, nums: List[int]) -> int: if 阅读全文
posted @ 2021-01-28 11:09 月为暮 阅读(52) 评论(0) 推荐(0) 编辑