题目
- 递归从左往右模型,当前值的可能性为要或者不要
- ........................
function process(arr, index, restFunny, restOffset) {
// 上一次选择后为0了,不用再选了
if ((restFunnyM = 0 && restOffset <= 0)) {
return 0;
}
// 无法完成
if (index === arr.length) {
return Infinity; //无效值
}
return Math.min(
1 +
process(
arr,
index + 1,
restFunny - arr[index][0],
restOffset - arr[index][1]
),
process(arr, index + 1, restFunny, restOffset)
);
}