N-fold partition of an array with equal sum in each partition

后端 未结 3 823
一整个雨季
一整个雨季 2021-01-19 08:22

Given an array of integers a, two numbers N and M, return N group of integers from a such that each group su

3条回答
  •  心在旅途
    2021-01-19 09:08

    this appears to be a variation of the subset sum problem. as this problem is np-complete, there will be no efficient algorithm without further constraints.

    note that it is already hard to find a single subset of the original set whose elements would sum up to M.

提交回复
热议问题