Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 6420 |

@blackshadows | 6376 |

@mb1973 | 5604 |

@Quandray | 5231 |

@akhayrutdinov | 5111 |

@saiujwal13083 | 4510 |

@sanjay05 | 3762 |

@kirtidee18 | 3673 |

@marius_valentin_dragoi | 3522 |

@sushant_a | 3459 |

@verma_ji | 3413 |

Complete Leaderboard | |

Handle | Score |

@codersgroup18 | 799 |

@sriramgoparaju99 | 737 |

@Manikanta punnam | 629 |

@rdakka | 606 |

@prankursharma31 | 597 |

@praveenbgp6 | 546 |

@sanskar94511 | 531 |

@purohitmn02 | 529 |

@yashkaril4 | 517 |

@abhikarshgupta | 474 |

@rohitgarg2825 | 464 |

Complete Leaderboard |

Given an array **arr[]** of size **N**, check if it can be partitioned into two parts such that the sum of elements in both parts is the same.

**Example 1:**

**Input:** N = 4
arr = {1, 5, 11, 5}
**Output:** YES
**Explaination:**
The two parts are {1, 5, 5} and {11}.

**Example 2:**

**Input:** N = 3
arr = {1, 3, 5}
**Output:** NO
**Explaination: **This array can never be
partitioned into two such parts.

**Your Task:**

You do not need to read input or print anything. Your task is to complete the function **equalPartition()** which takes the value N and the array as input parameters and returns 1 if the partition is possible. Otherwise, returns 0.

**Expected Time Complexity:** O(N*sum of elements)

**Expected Auxiliary Space:** O(N*sum of elements)

**Constraints:**

1 ≤ N ≤ 100

1 ≤ arr[i] ≤ 1000

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes
Partition Equal Subset Sum

...