Skip to content

Commit a8ca12f

Browse files
authored
Update 1449-form-largest-integer-with-digits-that-add-up-to-target.js
1 parent 1b1fed4 commit a8ca12f

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

1449-form-largest-integer-with-digits-that-add-up-to-target.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@ const largestNumber = function(cost, target) {
1111
function dfs(cost, index, remain, m) {
1212
if(remain === 0) return ''
1313
if(remain < 0 || index === cost.length + 1) return '0'
14-
const k = `${index}-${remain}`
15-
if(m.has(k)) return m.get(k)
14+
if(m.has(remain)) return m.get(remain)
1615
const take = '' + index + dfs(cost, 1, remain - cost[index - 1], m)
1716
const skip = dfs(cost, index + 1, remain, m)
1817
const res = getBigger(take, skip)
19-
m.set(k, res)
18+
m.set(remain, res)
2019
return res
2120
}
2221
function getBigger(num1, num2) {

0 commit comments

Comments
 (0)