Challenge: The Partition Problem

Let's write code to solve the partition problem!

Problem statement

Given a list of integers, write a function to find if any two subsets of the input list exist—such that the sum of both subsets is equal. You can assume that the list will only consist of positive integers.


A list of positive integers


A boolean. True if such subsets exist and False if they do not

Sample input

 set = [1, 2, 3, 4] 

Sample output

result = True # (The 2 subsets will be 1,4 & 2,3)

Coding Challenge

First, take a close look at this problem and design a step-by-step algorithm before jumping to the implementation. This problem is designed for your practice, so try to solve it on your own first. If you get stuck, you can always refer to the solution provided in the solution section. Good luck!

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.