getting WA

Where is the code wrong…

Q Given an array is it possible to divide array in two parts with equal sum?

give some test cases where the code breaks.

Thanks in advance.

Your code gives output NO for:


5 6 7 7 19 20

But, 20+5+7=19+6+7.

Google “balanced partition problem” for help.

Your Logic is wrong.

It can be solved using backtracking.

Here’s my code - link

Are we supposed to divide them into two consecutive sub arrays??

Also post link to the problem statement.