mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-05 16:26:47 +08:00
Dynamic-Programming : remove live code & console.log, leave examples as comments.
This commit is contained in:
@ -20,7 +20,7 @@ const zeroOneKnapsack = (arr, n, cap, cache) => {
|
||||
}
|
||||
}
|
||||
|
||||
const main = () => {
|
||||
const example = () => {
|
||||
/*
|
||||
Problem Statement:
|
||||
You are a thief carrying a single bag with limited capacity S. The museum you stole had N artifact that you could steal. Unfortunately you might not be able to steal all the artifact because of your limited bag capacity.
|
||||
@ -40,6 +40,8 @@ const main = () => {
|
||||
input.shift()
|
||||
const length = input.length
|
||||
|
||||
let output = []
|
||||
|
||||
let i = 0
|
||||
while (i < length) {
|
||||
const cap = Number(input[i].trim().split(' ')[0])
|
||||
@ -62,9 +64,11 @@ const main = () => {
|
||||
cache.push(temp)
|
||||
}
|
||||
const result = zeroOneKnapsack(newArr, currlen, cap, cache)
|
||||
console.log(result)
|
||||
output.push(result)
|
||||
i += currlen + 1
|
||||
}
|
||||
|
||||
return output
|
||||
}
|
||||
|
||||
main()
|
||||
export { zeroOneKnapsack, example }
|
||||
|
Reference in New Issue
Block a user