思路:
1. 假设当前剩余总和小于最大值:
a.循环当前剩余数字
b.递归运行
c. 用一个变量bestS存小于最大值情况下的最大总和
var bestS = {val:0,str:""};var LIMIT ;Array.prototype.sum = function(){var s = 0;for(var i = 0;i < this.length;i++){s+= this[i];}return s;}function f(bagArr,copyArr,start){var arrS = copyArr.sum();if(arrS < LIMIT && arrS > bestS.val){bestS = arrS > bestS.val ? {val:arrS,str:copyArr.join(',')} : bestS; }for(var i = start;i