I need to find sum of product of element in every subset of an array in polynomial time complexity.
e.g., for array {1,2,3}
required sum will be equal to null+1+2+3+(1*2)+(1*3)+(2*3)+(1*2*3)
.
All I know is brute-force approach to this problem. Can someone explain how to solve this problem using dynamic programming in O(n^2)
or O(n^3)
time complexity?