Home > other >  For an algorithm about the array of split.
For an algorithm about the array of split.

Time:09-21

Existing an array, including M Numbers, to be broken up into N array, to ensure that each array is not greater than the sum of constant value under the condition of L, how to do let N minimum,

CodePudding user response:

Under the condition of no account of time space complexity, a form of thinking, try it,
For each element in the original array, calculation of subarray, led by it, the minimum and the minimum and the corresponding end element position, and then start from the first element, and determine the boy array, if less than or equal to the limit, then again from the sequence to the end of the ward to find a can satisfy the allowable value of remaining subsequence, until find the subsequence, put this together string son sequence string up to the first eligible array, remove and then after the rest of the array to find qualified record, until you find all elements, or the rest of the can't find the qualified sequence in the array
  • Related