Search for a tool
Subset Sum

Tool to calculate the sum of subsets, solve the subset sum problem, and test combinations of numbers quickly and for free online.

Results

Subset Sum -

Tag(s) : Arithmetics, Combinatorics

Share
Share
dCode and more

dCode is free and its tools are a valuable help in games, maths, geocaching, puzzles and problems to solve every day!
A suggestion ? a feedback ? a bug ? an idea ? Write to dCode!


Please, check our dCode Discord community for help requests!
NB: for encrypted messages, test our automatic cipher identifier!


Feedback and suggestions are welcome so that dCode offers the best 'Subset Sum' tool for free! Thank you!

Subset Sum

Subset Sum Problem Solver










Integer Partitions Generator

⮞ Go to: Number Partitions

Answers to Questions (FAQ)

What is the Sum of Subsets problem? (Definition)

The subset sum problem (SSP) is a classic problem in theoretical computer science and combinatorial optimization.

It consists of determining whether there exists a subset of a given set of integers whose sum equals a given target value.

Formally, given a set $ A = \{n_1, n_2, \ldots, n_n\} $ and a target $ N $, the goal is to find a subset $ B \subseteq A $ such that the sum of the elements of $ B $ equals $ N $, i.e., $ \sum n_{i \subseteq B} = N $

Example: $ S = \{3, 5, 2, 7\} $ and $ N = 10 $, then the subset $ \{3, 7\} $ is a solution, since $ 3 + 7 = 10 $

How to solve the problem of the sum of subsets?

— Naive approach (brute force): Test all possible combinations of subsets. This method has an exponential complexity of $ O(2^n) $, making it inefficient for large sets.

— Dynamic programming: Use a table to store the sums feasible with the subsets. The complexity is $ O(n \times N) $, where $ n $ is the size of the set and $ N $ is the target value.

— Approximation algorithms: For large instances, algorithms like Meet-in-the-Middle reduce the complexity to $ O(2^{n/2}) $

What is the difference with the Knapsack problem?

The knapsack problem generalizes the sum of subsets by assigning a weight and a value to each element.

In the knapsack problem, the goal is to maximize the total value without exceeding a given capacity, whereas the sum of subsets focuses solely on the sum of the elements.

What is the difference with partitions of integers?

By allowing repetition of elements in the sum of subsets, then the subset problem is a variant of integer partitions restricted to a given set.

Source code

dCode retains ownership of the "Subset Sum" source code. Any algorithm for the "Subset Sum" algorithm, applet or snippet or script (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, breaker, translator), or any "Subset Sum" functions (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) or any database download or API access for "Subset Sum" or any other element are not public (except explicit open source licence). Same with the download for offline use on PC, mobile, tablet, iPhone or Android app.
Reminder: dCode is an educational and teaching resource, accessible online for free and for everyone.

Cite dCode

The content of the page "Subset Sum" and its results may be freely copied and reused, including for commercial purposes, provided that dCode.fr is cited as the source (Creative Commons CC-BY free distribution license).

Exporting the results is free and can be done simply by clicking on the export icons ⤓ (.csv or .txt format) or ⧉ (copy and paste).

To cite dCode.fr on another website, use the link: https://www.dcode.fr/subset-sum

In a scientific article or book, the recommended bibliographic citation is: Subset Sum on dCode.fr [online website], retrieved on 2026-01-11, https://www.dcode.fr/subset-sum

Need Help ?

Please, check our dCode Discord community for help requests!
NB: for encrypted messages, test our automatic cipher identifier!

Questions / Comments

Feedback and suggestions are welcome so that dCode offers the best 'Subset Sum' tool for free! Thank you!


https://www.dcode.fr/subset-sum
© 2026 dCode — The ultimate collection of tools for games, math, and puzzles.
â–˛  
Feedback