合集-随机小题
摘要:分析: 做到简单题下班 把列表元素用字符串拼接,再化成整型算和 最后再拆分为单个元素,再化为整数 代码: 1 class Solution(object): 2 def addToArrayForm(self, num, k): 3 """ 4 :type num: List[int] 5 :typ
阅读全文
摘要:分析: 简单题,直接写 但是做题有个问题,思考不够全面,往往开始只过了案例 没有想到其他情况 代码: 1 class Solution(object): 2 def maximumProduct(self, nums): 3 """ 4 :type nums: List[int] 5 :rtype:
阅读全文
摘要:分析: 题目意思是数组里面能组合起来最长的连续数组 然后直接sort排序,如果中间差数不是1就不再连续,count归零 当nums[i]和nums[i-1]相等的时候,跳过 代码: 1 class Solution(object): 2 def longestConsecutive(self, nu
阅读全文
摘要:分析: 题目有点绕,但是大概意思就是给出的数组是多个任务 logs[i][0]是员工编号,logs[i][1]是处理完当前i任务结束的时间 而i任务需要的时间就是logs[i][1]-logs[i-1][1] 求得最长的任务时间,如果有多个,就取员工编号最小的那个 建立一个maxes量存最大时间,一
阅读全文
摘要:分析: 本来刷二分的,但是这道题不用双指针也能做 所以就偷个懒,加上数组范围小,遍历就行 代码: 1 class Solution(object): 2 def intersection(self, nums1, nums2): 3 """ 4 :type nums1: List[int] 5 :t
阅读全文
摘要:分析: 跟上道题一样,但是可以重复 代码: class Solution(object): def intersect(self, nums1, nums2): """ :type nums1: List[int] :type nums2: List[int] :rtype: List[int] "
阅读全文

浙公网安备 33010602011771号