How Sum with Tabulation
Updated: 01 February 2024
Problem
The same problem as the Memoization How Sum problem but we want to take a tabular approach which we can do as an adaptation of the Tabular Can Sum problem
For our purpose, let’s initialize the value as our return type of null
and instead of storing a boolean we will store the current array value which has lead to that sum thus far
At each step we replace the latter element and append the current value that we have
And so, our result is [3,4]
Tabulation Implementation
The implementation of this can be seen below:
In the above, the time complexity and space complexity
The reason we say and not in the time complexity is because of the array copy operation that we do to assign the latest value