Does anyone have any ideas for this algorithms problem?
Given an array A with 40 integers (-10^9 < Ai < 10^9), how many ways are there to reach a target sum X.
Normally, I would use dynamic programming, however the space complexity is too large, as a 10^9 array would give me a runtime error.
The brute force would obviously not work as 2^40 is far too large. There is an algorithm that in theory works in O(2^(N/2)) which would work in this scenario, however it seems far too complicated for this problem.
Is there another approach or optimization that I am missing?