Need space optimisation approach for the dp question and Mention the Time Complexity of the answer

Правка en1, от anmolsainiii23, 2024-05-13 10:16:35

You are given an array of n elements and a sum value, you have to calculate the total number of ways to calculate the given sum using the elements of the array by using only addition(+) and subtraction operator(-).

Value of n should lie between [1,15]

array => [-1, 9, 8, -3, 4] value sum => 5

Output -: 8

I have applied Recursion and Memo also but I want a space Optimization Approach for this Question. Please Explain the Working and Time Complexity of this Code and share the Code snippet.

Теги dp, recursion, memoization, pattern

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский anmolsainiii23 2024-05-13 10:16:35 606 Initial revision (published)