Function
update
(nums, numIndex, subSetSum, tabu)
Source from the content-addressed store, hash-verified
| 147 | }; |
| 148 | |
| 149 | var update = (nums, numIndex, subSetSum, tabu) => { |
| 150 | const num = numIndex - 1; |
| 151 | const prevNum = nums[num]; |
| 152 | |
| 153 | for (let subSet = 0; subSet <= subSetSum; subSet++) { |
| 154 | /* Time O(M) */ |
| 155 | const isNumGreater = subSet < prevNum; |
| 156 | |
| 157 | tabu[numIndex][subSet] = isNumGreater /* Space O(N * M) */ |
| 158 | ? tabu[num][subSet] |
| 159 | : tabu[num][subSet] || tabu[num][subSet - prevNum]; |
| 160 | } |
| 161 | }; |
| 162 | |
| 163 | /** |
| 164 | * DP - Bottom Up |
Tested by
no test coverage detected