Let's now discuss the space and time complexity for the tabulation approach that we have just now discussed.
So notice over here, the tabulation approach is iterative in nature.
And we will not be using space on the recursive call stack.
So the space complexity but still is of the order of n into w because we have this DP table.
And you can see that it has n rows and w columns.
So the space complexity is of the order of n into w.
And the time complexity is also of the order of n into W.
Because as you have seen, we are going row by row and filling each of the cells over here.
So the space complexity and time complexity of this solution is of the order of n into W.