Skip to content

Conversation

@AliAlimohammadi
Copy link

Description

This PR implements the Subset Sum Problem using dynamic programming. The algorithm determines whether there exists a subset of a given array that sums to a specified target value.

The implementation uses a 2D DP table where dp[i][j] represents whether sum j can be achieved using the first i elements of the array. This is a classic dynamic programming problem with applications in resource allocation, partitioning, and combinatorial optimization.

  • Implements subset sum problem using DP approach
  • Includes comprehensive test cases with edge cases (empty arrays, zero sum, single elements)
  • Time complexity: O(n * sum) where n is array length and sum is the target value
  • Space complexity: O(n * sum) for the DP table

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist:

  • I ran below commands using the latest version of rust nightly.

  • I ran cargo clippy --all -- -D warnings just before my last commit and fixed any issue that was found.

  • I ran cargo fmt just before my last commit.

  • I ran cargo test just before my last commit and all tests passed.

  • I added my algorithm to the corresponding mod.rs file within its own folder, and in any parent folder(s).

  • I added my algorithm to DIRECTORY.md with the correct link.

  • I checked CONTRIBUTING.md and my code follows its guidelines.

  • Code structure follows repository patterns

  • All tests are included and logically sound

  • Documentation is comprehensive with examples

- Implements subset sum problem using DP approach - Includes comprehensive test cases with edge cases - Time complexity: O(n * sum) - Space complexity: O(n * sum)
@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.44%. Comparing base (13710a7) to head (a2fe724).

Additional details and impacted files
@@ Coverage Diff @@ ## master #956 +/- ## ========================================== + Coverage 95.39% 95.44% +0.05%  ========================================== Files 332 333 +1 Lines 21496 21524 +28 ========================================== + Hits 20506 20544 +38  + Misses 990 980 -10 

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants