For each element of arr [ ] , we loop through all elements of DP table from 1 to m and we add current element i . e . , arr [ i ] to all those elements which are true in DP table
for ( int j = 0 ; j < m ; j ++ ) {