leetcode:三个无重叠子数组的最大和(dfs剪枝超时)
思路: 昨天刚做出来一道bfs,今天拿到就想无脑dfs,然后就超时了5555
代码:
class Solution:
def maxSumOfThreeSubarrays(self, nums: List[int], k: int) -> List[int]:
# 先计算k个和
sum_list = []
for i in range(len(nums) - k + 1):
temp = 0
for j in range(k):
temp += nums[i + j]
sum_list.append(temp)
self.res = []
self.maxn = 0
def dfs(
共有 0 条评论