educative.io

Educative

Partition Problem: All provided solutions are wrong

All provided solutions fail a simple test

[2,5,5,10]

Fixed by removing the cryptic part of the code where the sum gets divided by two.

Can someone explain why?

@Jason_Zhou
Hi, I think the question is to divide the complete array into 2 parts using all the elements. lets say if we are considering your test case. the possible subsets pairs will be {{2}, {5, 5, 10}}, {{2, 5}, {5, 10}}, {{2, 5, 5}, {10}}… so on. None of the pairs meet the required criteria of equal sum. that’s why the solutions returned false.

I think the problem statement should be reframed a bit for easier understanding.