category-wise-problems

contains category wise problems(data structures, competitive) of popular platforms.

View the Project on GitHub mayankdutta/category-wise-problems

Two Sets II , Base on 01 Knapsack

iterative approach
Code sample ```cpp long long int n; cin >> n; long long int target = n * (n + 1) / 2; if (target & 1) { cout << 0 << '\n'; return; } target /= 2; vector<vector> dp(n + 1, vector(target + 1)); dp[0][0] = 1; for (int i = 1; i < n; i++) { /* OUTER KNAPSACK LOOP */ for (int j = 0; j <= target; j++) { dp[i][j] += dp[i - 1][j]; int rem = j - i; if (rem >= 0) { dp[i][j] += dp[i - 1][rem]; dp[i][j] %= mod; } } } cout << dp[n - 1][target] << '\n'; ``` </details>