Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

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

Правка en3, от 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

Теги #c++, #dynamic programmign, #memoization, #c++ 17

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en5 Английский SHUVRO.C.DAS 2021-01-09 12:33:27 4 Tiny change: ' it works takes a l' -> ' it works but takes a l'
en4 Английский SHUVRO.C.DAS 2021-01-09 11:57:03 39
en3 Английский SHUVRO.C.DAS 2021-01-09 11:54:35 1141
en2 Английский SHUVRO.C.DAS 2021-01-09 11:53:11 6
en1 Английский SHUVRO.C.DAS 2021-01-09 11:52:15 1859 Initial revision (published)