题目如下: Given an integer array A, you partition the array into (contiguous) subarrays of length at most K.  After partitioning, each subarray has their values changed to become the maximum value of that subarray. Return the largest sum of the given arr…
题目如下: 解题思路:本题是[leetcode]473. Matchsticks to Square的姊妹篇,唯一的区别是[leetcode]473. Matchsticks to Square指定了分成四个子数组,而本题分成的份数不定,作为参数输入.另外,本题的测试用例好像复杂一点,因此我过滤掉了nums中值等于avg的元素,不参与后面的DFS计算,提高效率. 代码如下: class Solution(object): def canPartitionKSubsets(self, nums,…
原题链接在这里:https://leetcode.com/problems/partition-array-for-maximum-sum/ 题目: Given an integer array A, you partition the array into (contiguous) subarrays of length at most K.  After partitioning, each subarray has their values changed to become the ma…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 日期 题目地址:https://leetcode.com/problems/partition-array-into-three-parts-with-equal-sum/ 题目描述 Given an array A of integers, return true if and only if we can partition the array…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址: https://leetcode.com/problems/partition-array-into-disjoint-intervals/description/ 题目描述: Given an array A, partition it into two (contiguous) subarrays left and right so that: Every elemen…
题目如下: Given an array A of integers, return true if and only if we can partition the array into three non-emptyparts with equal sums. Formally, we can partition the array if we can find indexes i+1 < j with (A[0] + A[1] + ... + A[i] == A[i+1] + A[i+2]…
题目如下: 解题思路:题目要求的是在数组中找到一个下标最小的index,使得index左边(包括自己)子序列的最大值小于或者等于右边序列的最小值.那么我们可以先把数组从最左边开始到数组最右边所有子序列的最大值都求出来存入leftMax数组,同时也把从数组最右边开始到最左边的所有子序列的最小值求出来存入rightMin数组,最后找出最小的i使得leftMax[i] <= rightMin[i+1]即可. 代码如下: class Solution(object): def partitionDisj…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 回溯法 日期 题目地址:https://leetcode.com/problems/partition-to-k-equal-sum-subsets/description/ 题目描述 Given an array of integers nums and a positive integer k, find whether it's possibl…
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 暴力 日期 题目地址:https://leetcode-cn.com/problems/split-array-with-equal-sum/ 题目描述 Given an array with n integers, you need to find if there are triplets (i, j, k) which satisfies fol…
[LeetCode]659. Split Array into Consecutive Subsequences 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址:https://leetcode.com/problems/split-array-into-consecutive-subsequences/description/ 题目描述: You are g…