Knapsack Bitset Reach Problem
Knapsack Bitset Reach Problem — ExecCode Hard DSA Practice
Solve the Knapsack Bitset Reach problem on ExecCode. Free online hard DSA practice in DP. Write and run code in Java, C++, Python — no signup required to run.
Problem description
You have coin values nums (each used at most once). Can you make exactly target? The DP reach |= reach << x uses word-level bitset parallelism instead of a bool array loop. Return 1 if some subset sums to target, else 0. Target 0 is always possible (empty subset). You are given: nums — coin values target — desired sum Return 1 or 0. Order does not matter. Each number at most once.
Examples
Input {'nums': [2, 3, 5], 'target': 7}; Output 1. Input {'nums': [2, 4], 'target': 5}; Output 0. Input {'nums': [1], 'target': 0}; Output 1
Constraints
Values are non-negative in tests Negative target is 0
Practice Knapsack Bitset Reach free on ExecCode. Browse DSA problems, topic map, and placement guides.