priyesh001's blog

By priyesh001, history, 6 years ago, In English

I have been learning DP from basic since last couple of days and I thought of solving all DP tagged problems from basic by filtering into the problem set by tag and complexity. I tried this filter (https://codeforces.net/problemset?tags=dp,1-1000) and found few problems which I didn't find related to DP. Are these incorrectly tagged as DP problem or is there something which I'm missing in these problems?

If these are incorrectly tagged as DP then would request to correctly tag the problems as it helps newbie's like me to filter problems and practice concepts.

Any help would be much appreciated.

Thanks.

Full text and comments »

  • Vote: I like it
  • +5
  • Vote: I do not like it

By priyesh001, 7 years ago, In English

Given an array S of N positive integers, divide the array into two subsets such that the sums of subsets is maximum and equal. It is not necessary to include all the elements in the two subsets. Same element should not appear in both the subsets. The output of the program should be the maximum possible sum.

Constraints:
1 <= N <= 50
1 <= S[i] <= 1000
Sum of elements of S will not be greater than 1000.
Example:
Input:
5
2 3 4 1 6
Output:
8 {Explanation: The two subsets with maximum sum are [1,3,4] and [2,6]}

I found this question in one of the interview challenge. I used the traditional sum of subsets logic to find all the possible sum for n elements and then tried to reconstruct non-overlapping subsets for a sum from the 2D DP array. I couldn't get all tc to pass. Is there any better easier solution for this?

Full text and comments »

  • Vote: I like it
  • -1
  • Vote: I do not like it