第三题在这里https://leetcode-cn.com/problems/contiguous-array/ 发一个python哈希表+前缀后解法 时间复杂度O(n) class Solution: def findMaxLength(self, nums: List[int]) -> int: lookup = {0:-1} total = 0 max_len = 0 for i in range(len(nums)): total += 1 if nums[i]==1 else -1 if total in lookup: max_len = max(max_len, i-lookup[total]) else: lookup[total]=i return max_len
点赞 评论

相关推荐

牛至超人:哈工大已经很棒了,不需要加括号了,然后咋没有实习经历呢?火速趁寒假整一段实习,导师不让就狠狠肘击
投了多少份简历才上岸
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务