Please read the new rule regarding the restriction on the use of AI tools. ×

How to find the shortest array where the sum of the elements of the array is equal to the given sum??

Revision en3, by SHUVRO.C.DAS, 2021-01-09 11:54:35

I am currently learning dynamic programming. While writing the code of best sum memoization I am facing a problem.

Problem Statement:

"write a function bestsum(target sum, argument) that takes a target sum and an array of integers as argument. the function should return an array containing the shortest combination of the target sum. we can use an element of the array more than one."

example: input- 10 3 2 3 1 output-3 3 2 2

I tried to solve it. it works takes a lot of time. How to solve it using dp memoization with c++???

*******my code link = https://github.com/Shuvro-d/Dynamic.Programming/blob/main/test%202.cpp

Tags #c++, #dynamic programmign, #memoization, #c++ 17

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en5 English SHUVRO.C.DAS 2021-01-09 12:33:27 4 Tiny change: ' it works takes a l' -> ' it works but takes a l'
en4 English SHUVRO.C.DAS 2021-01-09 11:57:03 39
en3 English SHUVRO.C.DAS 2021-01-09 11:54:35 1141
en2 English SHUVRO.C.DAS 2021-01-09 11:53:11 6
en1 English SHUVRO.C.DAS 2021-01-09 11:52:15 1859 Initial revision (published)