There's an algorithm problem.

there are N positive integers in an array. I hope to find out that the sum of M numbers is equal to or closest to a positive integer S

.

for example, this array [1, br 2, 4, 6, 8, 10, 15, 16, 16, and 19], I hope to find out that the sum of 5 numbers is equal to 15, but there are multiple results [1, 2, 4, 4, 8] = 21 [1, 2, 4, 4, 6, 13, to see which is the higher weight of M and S, to sort

.
Php
Nov.27,2021
Menu