Jump to content

Featured Replies

Create an algorithm for the Subset Sum problem that runs in time O(nK) or better. Given a set X = {x1, x2, …, xn} of n integers and another integer K, the algorithm should check if there is a subset X' of X whose elements sum to K and if so, it should find this subset. For example, if X = {5, 3, 11, 8, 2} and K = 16, the algorithm should answer YES since the subset X' = {5, 11} has a sum of 16.

I have referred to this code from the issue I'm trying to solve: please stop spamming us with advertising!

I believe that utilizing dynamic programming techniques can improve the complexity of the problem from O(nK) to something lower.

I have discovered an algorithm that runs in exponential time, but it has not been of any assistance.

Is there anyone who can help me with this issue?

Please sign in to comment

You will be able to leave a comment after signing in

Sign In Now

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.