Category : knapsack-problem

When I am changing the order of isPossible function then it’s giving wrong answer otherwise present code gives correct answer. I wanted to know why this is happening. Here is the problem statement: Here is my accepted solution class Solution { unordered_map<int, bool> um; public: bool isPossible(vector<int>&nums, int currentIndex, int sum){ if(sum == 0){ ..

Read more