id int64 1 3.58k | problem_description stringlengths 516 21.8k | instruction int64 0 3 | solution_c dict |
|---|---|---|---|
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\n private:\n void solve(vector<int> arr, vector<int>& ds,vector<vector<int>> &ans,int target ,int index){\n if(index < 0){\n if(target==0){\n ans.push_back(ds);\n }\n return;\n }\n\n //pick element \n if(targ... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n void f(int i, int sum, vector<int>&v, vector<vector<int>>&ans, vector<int>nums){\n\n if(i < 0){\n if(sum == 0) ans.push_back(v);\n return ;\n }\n\n f(i-1, sum, v, ans, nums);\n\n if(nums[i] <= sum){\n v.push_back(n... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n\n void calculate( int index, int target, int n, vector<int> currentCombo, vector<vector<int>> &ans, vector<int> &candidates ){\n\n if( target == 0 ){\n ans.push_back( currentCombo );\n return;\n }\n if( target < 0 || index >= n )\n ... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n\n void calculate( int index, int target, int n, vector<int> currentCombo, vector<vector<int>> &ans, vector<int> &candidates ){\n\n if( target == 0 ){\n ans.push_back( currentCombo );\n return;\n }\n if( target < 0 || index >= n )\n ... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n bool already_in_solution(const set<vector<int>> &solutions, vector<int> check) {\n std::sort(check.begin(), check.end());\n return solutions.contains(check);\n }\n\n void backtrack(set<vector<int>> &solutions, vector<int> &combo, const int sum, const vecto... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\n void recurse(int idx, int sum, vector<int>combination, vector<int>&candidates, int &target, set<vector<int>>&uniques){\n if(idx==candidates.size()){\n return;\n }\n if(sum == target){\n uniques.insert(combination);\n return;\n ... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\nset<vector<int>> g;\n void check(vector<vector<int>> &r, int i, int s, int t, vector<int> v, vector<int>& c) {\n if(s==t && g.find(v)==g.end()) {\n r.push_back(v);\n g.insert(v);\n v.empty();\n return ;\n }\n if(... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n set<vector<int>> g;\n void check(vector<vector<int>> &r, int i, int s, int t, vector<int> v, vector<int>& c) {\n if(s==t && g.find(v)==g.end()) {\n r.push_back(v);\n g.insert(v);\n v.empty();\n return ;\n }\n ... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\nvoid helper(vector<int>& candidates,vector<vector<int>>& ans,int i,int target,vector<int> v){\n int sum=accumulate(v.begin(),v.end(),0);\n if(i==candidates.size()){\n if(sum==target)\n ans.push_back(v);\n return;\n }\n helper(candidates,ans,i+1,ta... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\nvoid helper(vector<int>& candidates,vector<vector<int>>& ans,int i,int target,vector<int> v){\n int sum=accumulate(v.begin(),v.end(),0);\n if(i==candidates.size()){\n if(sum==target)\n ans.push_back(v);\n return;\n }\n helper(candidates,ans,i+1,ta... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n\n void solve(vector<vector<int>>&ans, vector<int>temp, int t, int ind, vector<int>&c){\n if(ind == c.size()){\n if(t == 0) ans.push_back(temp);\n return;\n }\n if(t>=c[ind]){\n temp.push_back(c[ind]);\n solve(a... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n void create(int index, int target, vector<int> &candidates, vector<vector<int>> &res, vector<int> ds)\n {\n if(index >= candidates.size())\n {\n if(target==0)\n {\n res.push_back(ds);\n }\n return;\n ... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution\n{\npublic:\n vector<vector<int>> ans;\n void fun(vector<int> &candi, int target, int indx, vector<int> cur)\n {\n if (indx >= candi.size())\n {\n if (target == 0)\n {\n ans.push_back(cur);\n }\n return;\n ... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n void helper(vector<int> candidates, int target, vector<vector<int>>& ans, int index, vector<int>& subset){\n\n if(!target){\n ans.push_back(subset);\n return ;\n }\n\n if( target < 0 || index == candidates.size()){\n retur... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\n public:\n vector<vector<int>>res;\n public:\n void fun(int n,vector<int>& candidates, int Requiredtarget,vector<int> elligiblecandidates)\n {\n if(Requiredtarget==0)\n {\n res.push_back(elligiblecandidates);\n return;\n }\n ... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\n vector<vector<int>> ans;\n\n void f(vector<int> v, int idx, int target, vector<int>& sub){\n if(target == 0){\n ans.push_back(sub);\n return;\n }\n if(idx >= v.size()) return;\n if(v[idx] <= target){\n sub.push_back(v[idx... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n vector<vector<int>> combinationSum(vector<int>& candidates, int target) {\n //sort(candidates.begin(), candidates.end());\n\n map<int, set<vector<int>>> temp;\n\n set<vector<int>> out;\n for (auto it = candidates.begin(); it != candidates.end(); it... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n\n set<multiset<int>> memo[41];\n bool hasMemo[41];\n\n vector<vector<int>> combinationSum(vector<int>& candidates, int target) {\n for (int i = 0; i < 41; i++) {\n hasMemo[i] = false;\n }\n auto retSets = combinationSumSets(candidates, ta... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n void fun(int i, int n, int sum, vector<int> t, int target, vector<vector<int>> &ans, vector<int>& candidates)\n {\n if(sum==target)\n {\n ans.push_back(t);\n return ;\n }\n if(i>=n || sum>target)\n {\n ... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n\n void f(vector<int>&arr, int t, int i, int sum, vector<int> temp, int n, vector<vector<int>> &ans)\n {\n if (i == n)\n {\n if (sum == t)\n {\n ans.push_back(temp);\n }\n return;\n }\n\n ... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n\n void func(int target, int index, vector<int>& arr, vector<int>ans, vector<vector<int>>&finalans, int n){\n if(target==0){\n finalans.push_back(ans); return ; \n }\n if(index>=n) return ; \n if(target-arr[index] >=0 ){\n a... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n void solve(int index, int req, vector<int> sub, int n, vector<vector<int>>& ans, vector<int>& candidates) {\n //if index reach to end and check all base case is reach atstep where base case reach if req is==0 then given sub is one ans\n if (index == n || req==0)... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n void combinationSumRecu(vector<vector<int>> &res, vector<int>& arr, vector<int> curr, int target, int n) {\n if(target == 0) {\n res.push_back(curr);\n return;\n }\n if(n<=0 || target < 0) {\n return;\n }\n combinationSumRecu(res,... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n vector<vector<int>> combinationSum(vector<int>& candidates, int target) {\n vector<vector<int>> res;\n for (int i = 0; i < candidates.size(); i++) {\n if (target > candidates[i]) {\n vector<vector<int>> prev = combinationSum(candidates,... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n void fun(vector<int>&candidates,int n,vector<vector<int>>&res,int k,vector<int>v)\n {\n if(n<0 || k<0)\n return;\n if(k==0)\n {\n res.push_back(v);\n return;\n }\n\n fun(candidates,n-1,res,k,v);\n v... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\n void help(int i, vector<int>& candidates, int target, vector<int>temp, vector<vector<int>>& res) {\n if(i<0 || target<0) return;\n if(target==0) {\n res.push_back(temp);\n return;\n }\n\n temp.push_back(candidates[i]);\n help(i,... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n vector<vector<int>> vec;\n void com(vector<int>& candidates,int n, int target, int sum, vector<int> v)\n {\n if(sum == target)\n {\n vec.push_back(v);\n return;\n }\n if(sum > target || n < 0)\n return;\n v... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n void f(int ind, set<vector<int>>& s, vector<int> &vec, vector<int> can,int target)\n {\n if(target<0 || ind<0) return ;\n \n if(target==0)\n {\n s.insert(vec);\n }\n vec.push_back(can[ind]);\n f(ind, s, vec, can, ... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n set<vector<int>> ans;\n void helper(vector<int>p, vector<int>v, int cur,int target,int index){\n if(cur==target){\n ans.insert(v);\n return;\n }\n if(index>=p.size())return;\n if(cur>target) return;\n\n if(cur+p[inde... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\n void f(vector<int>& candidates,int target,int i,int &count,int sum,vector<int>v1,vector<vector<int>> &res,map<vector<int>,int> &m1)\n {\n if(sum>target)\n {\n return;\n }\n if(sum==target && !m1[v1])\n {\n res.push_back(v1);\... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n void solve(int i, int target, vector<int> v, vector<int> temp, vector<vector<int>> &ans){\n if(target == 0){\n ans.push_back(temp);\n return;\n } \n \n if(i < 0 || target < 0) {\n return;\n }\n \n ... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n void solve(int i, int target, vector<int> v, vector<int> temp, vector<vector<int>> &ans){\n if(target == 0){\n ans.push_back(temp);\n return;\n } \n \n if(i < 0) {\n return;\n }\n \n if(v[i]<... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\nprivate:\n vector<vector<int>> ans;\n void f(vector<int>&v,int i,int target,vector<int>ds){\n if(i==v.size()){\n if(target==0){\n ans.push_back(ds);\n ds.clear();\n }\n return;\n }\n if(target>=v[i])... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\nprivate:\n vector<vector<int>> ans;\n void f(vector<int>&v,int i,int target,vector<int>ds){\n if(i==v.size()){\n if(target==0){\n ans.push_back(ds);\n }\n return;\n }\n if(target>=v[i]){\n f(v,i+1,target... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n vector<vector<int>> res;\n void comb(vector<int>& nums, vector<int> tmp, int tgt){\n if(tgt == 0){\n sort(tmp.begin(), tmp.end());\n if(find(res.begin(), res.end(), tmp) == res.end())\n res.push_back(tmp);\n return;\n ... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n void function(vector<int>& candidates, int target,vector<int> temp,vector<vector<int>> &ans,int ind){\n if(target==0)\n {\n sort(temp.begin(),temp.end());\n if(find(ans.begin(),ans.end(),temp)==ans.end())\n ans.push_back(temp);\n... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n void solve(vector<int>& candidates,int target, set<vector<int>>&s,vector<int>v){\n if(target==0){\n sort(v.begin(),v.end());\n s.insert(v);\n return;\n }\n for(int i=0;i<candidates.size();i++){\n if(candidates[i... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n void rec(vector<int> & candidate,int target,set<vector<int>>&st,vector<int>store){\n if(target==0){\n sort(store.begin(),store.end());\n st.insert(store);\n return ;\n }\n for(int i = 0;i<candidate.size();i++){\n ... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n\n void backTrack(int index, vector<int>& c, vector<vector<int>>& result, \n vector<int> temp, int& target, int currSum)\n {\n if(currSum > target || index >= c.size() || c[index] > target) return;\n\n if(currSum == target) \n {\n ... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n vector<vector<int>> combinationSum(vector<int>& candidates, int target) {\n set<vector<int>> ans;\n auto f = [&] (auto f, int i, vector<int> curr, int sum) -> void {\n if (i == -1) return;\n if (sum > target) return;\n if (sum ==... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n\n void solve(vector<int>& nums, int t, int n, int sum, int i, vector<int>& ds, set<vector<int>>& ans){\n if(i == n) return;\n if(sum == t){\n sort(ds.begin(), ds.end());\n ans.insert(ds);\n }\n else if(sum>t) return;\n ... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n set<vector<int>> ans;\n void solver(int n,vector<int> &a,vector<int> sub,int target)\n {\n if(n==0||target<0)\n {\n if(target==0)\n {\n sort(sub.begin(),sub.end());\n ans.insert(sub);\n }\n ... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "void combiSum(vector<int>& candidates, int target,vector<vector<int>> &ans, vector<int> v={}, int i=0) {\n if(i==candidates.size()){\n if (target == 0){\n ans.push_back(v);\n }\n return;\n }\n v.push_back(candidates[i]);\n if(candi... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n void uniqueCombinationSum(vector<int>& arr, vector<int>currComb, set< vector<int> >& result, int st, int X) {\n // This is used to take every element only once\n if (X <= 0 || st >= arr.size()) {\n return;\n }\n \n currComb.pu... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\n void solve(int ind, vector<int>path, vector<int>& candidates, int target, set<vector<int>>&s){\n if(target==0){\n s.insert(path);\n return;\n }\n\n if(target<0) return;\n\n \n for(int i=ind; i<candidates.size(); i++){\n ... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n void f(int ind, vector<int> ds, vector<vector<int>>& ans, vector<int>& candidates, int target, int sum){\n if(sum>target) return;\n if(ind==candidates.size()){\n if(sum==target) ans.push_back(ds);\n return;\n }\n sum+=candidat... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n void solve(vector<int> candidates,int target,int index,vector<int> temp,vector<vector<int>> &v){\n\n if(target==0){\n v.push_back(temp);\n return;\n }\n \n if(index>=candidates.size() || target<0) {\n return;\n }\n\n if(candidates[index]... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\nprivate:\n void solve(int index,vector<vector<int>> &ans,vector<int> temp,vector<int> candidates, int target){\n if(index==candidates.size() && target!=0 ) return;\n if( target==0){\n ans.push_back(temp);\n return;\n }\n\n //include \n ... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "#include<algorithm>\n#include<cmath>\nclass Solution {\npublic:\n vector<vector<int>> combinationSum(vector<int>& candidates, int target) {\n vector<vector<int>> res;\n vector<int> temp;\n helper(candidates,target,res,temp,0);\n return res;\n }\n vector<vector<int>> helpe... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "#include<algorithm>\n#include<cmath>\nclass Solution {\npublic:\n vector<vector<int>> combinationSum(vector<int>& candidates, int target) {\n vector<vector<int>> res;\n vector<int> temp;\n helper(candidates,target,res,temp,0);\n return res;\n }\n vector<vector<int>> helpe... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n void combinationSumUtil(vector<int> &A, int sum, \n vector<vector<int> >&result, vector<int> current, int pos)\n {\n \tif(sum==0){ \n \t\tresult.push_back(current);\n \t\treturn;\n \t}\n \tif(sum<0 || pos>=A.size()) \n \t\treturn; \n \n \tcurr... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n\n void solve(vector<int>& candidates, int &target, vector<vector<int>>& ans, vector<int> output, int index, int currSum) {\n\n if(currSum == target) {\n ans.push_back(output);\n return;\n }\n\n if(index >= candidates.size() || currSu... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n void sol(vector<int>candidate,vector<vector<int>>&v,vector<int>&w,int i,int t,int s){\n if(t==s){\n v.push_back(w);\n return;\n }\n if(t<s || i>=candidate.size()) return;\n w.push_back(candidate[i]);\n sol(candidate,v,w... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n void func(vector<int> arr, int index, int target, vector<int> &sumArr, vector<vector<int>> &finalAns){\n if(target == 0) {\n finalAns.push_back(sumArr);\n return;\n }\n if(target<0 || index>= arr.size()) return;\n \n su... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n vector<vector<int>> possible;\n void pcom(vector<int> candidates, vector<int> &st,int target, int i,int sum){\n if(sum>target || i==candidates.size()) return;\n if(sum==target){\n possible.push_back(st);\n return;\n }\n st.... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n void solve(vector<int> arr, int sum, int i, vector<int>& current,\n vector<vector<int>>& result) {\n\n if (sum == 0) {\n result.push_back(current);\n return;\n }\n\n if (i >= arr.size() || sum < 0) {\n return... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n vector<vector<int>> combinationSum(vector<int>& candidates, int target) {\n vector<vector<int>> output;\n set<vector<int>> uniqueCombinations;\n \n function<void(vector<int>, int)> recursion = [&](vector<int> currArr, int currTarget) {\n ... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n vector<vector<int>> combinationSum(vector<int>& candidates, int target) {\n vector<vector<int>> output;\n set<vector<int>> uniqueCombinations;\n \n function<void(vector<int>, int)> recursion = [&](vector<int> currArr, int currTarget) {\n ... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n vector<vector<int>> combinationSum(vector<int>& candidates, int target) {\n vector<vector<int>> sol;\n findCombos(candidates, target, sol, {}, 0, 0);\n return sol;\n }\n\nprivate:\n void findCombos(vector<int>& candidates, int& target, vector<vector... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n vector<vector<int>> combinationSum(vector<int>& candidates, int target) {\n vector<vector<int>> sol;\n findCombos(candidates, target, sol, {}, 0, 0);\n return sol;\n }\n\nprivate:\n void findCombos(vector<int>& candidates, int& target, vector<vector... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n\n void pairsWithSumK(vector<int> cand, int target, vector<vector<int>>& ans, vector<int>& temp, int sum, int i) {\n if(sum == target) {\n ans.push_back(temp);\n return;\n }\n\n if(i >= cand.size() || sum > target) return;\n \n... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n void recursion(vector<vector<int>> &ds, vector<int> candidates,vector<int> res, int target, int ind, int n){\n if(ind==n){\n if(target==0){\n ds.push_back(res);\n }\n return;\n }\n if(candidates[ind]<=target... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n void solve(int i, vector<int> nums, set<vector<int>> &ans, int target, vector<int> temp){\n if (i == nums.size()){\n if (target == 0){\n ans.insert(temp);\n }\n return;\n }\n if (nums[i] <= target){\n ... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n set<vector<int>> temp;\n vector<int>curr;\n void recursive_soln(vector<int>candidates,int index, int target){\n if(target==0){\n temp.insert(curr);\n return;\n }\n if(target<0) return;\n if(index>=candidates.size()) retu... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\n void solve(int i,vector<int>& candidates, int t,vector<vector<int>>&ans,vector<int>comb){\n if(i>=candidates.size()) return ;\n if(t==0){\n ans.push_back(comb);\n return ;\n }\n if(t<0) return;\n comb.push_back(candidates[i]);\n... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n void findSum(vector<int>& candidates, vector<vector<int>>& ans, vector<int> comb, int curr, int remaining){\n if(remaining<0 || curr>=candidates.size()){\n return;\n }\n if(remaining==0){\n ans.push_back(comb);\n return;\... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n\n void solve(vector<int> &arr, int n, int target, int i, int sum, vector<int> cur, vector<vector<int>> &ans)\n {\n if(i==n || sum>=target)\n {\n if(sum==target)\n {\n ans.emplace_back(cur);\n }\n\n ... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n vector<vector<int>> combinationSum(vector<int>& candidates, int target) {\n int n = candidates.size();\n vector<vector<int>>ans;\n vector<int>v1;\n int sum = 0;\n rec(candidates, target, 0, ans, n, sum, v1);\n return ans;\n }\n ... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n void combination(int ind,vector<int> &temp,vector<vector<int>> &ans,vector<int> num,int target,int cur){\n if(cur>target)return ;\n if(ind>=num.size()){\n if(cur==target){\n ans.push_back(temp);\n return;\n }\n... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\n void combSum(vector<vector<int> > &ans, vector<int> candidates, vector<int> &temp,int index, int sum) {\n if (sum < 0)\n return;\n if (index == candidates.size()) {\n if (sum == 0) {\n ans.push_back(temp);\n }\n retu... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n vector<vector<int>> res;\n void dfs(int idx, vector<int>& candidates, int n, int target, vector<int> temp, int tsum){\n if(tsum==target){\n res.push_back(temp);\n return;\n }\n if(idx==n || tsum>target)\n return;\n ... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n vector<vector<int>> combinationSum(vector<int>& candidates, int target) {\n dfs(0, 0, vector<int> (), candidates, target);\n\n return ans;\n }\n\n void dfs(int i, int currSum, vector<int> subset, vector<int>& candidates, int target){\n if(currSum > ... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n vector<vector<int>> helper(vector<int>& candidates, vector<int> combi,int idx,int sum, int target){\n vector<vector<int>> res;\n\n if(idx >= candidates.size() || target < 0)\n return res;\n\n res = helper(candidates, combi,idx+1,sum,target);\n\... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution\n{\nprivate:\n vector<vector<int>> result;\n int tar;\n vector<int> can;\n\n void dfs(int i, vector<int> cur, int total)\n {\n if (total == tar)\n {\n vector<int> copy = cur;\n result.push_back(copy);\n return;\n }\n\n if (i >= can.size() || total > tar)\n ... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n void func(vector<int> arr, int index, int target, vector<int> sumArr, vector<vector<int>> &finalAns){\n if(target<0) return;\n \n if(index == arr.size()){\n if(target == 0) {\n finalAns.push_back(sumArr);\n return;\... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n void combo(int index, int target, vector<int> ans,\n vector<int> candidates, vector<vector<int>>& res) {\n \n\n if (index == candidates.size()) {\n if (target==0) {\n res.push_back(ans);\n }\n return;\... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n void findCombination(int i,vector<int> cand,int target,vector<int> temp,set<vector<int>> &ans){\n if(i == cand.size()){\n if(target == 0){\n // ans.push_back(temp);\n ans.insert(temp);\n }\n return;\n ... |
39 | <p>Given an array of <strong>distinct</strong> integers <code>candidates</code> and a target integer <code>target</code>, return <em>a list of all <strong>unique combinations</strong> of </em><code>candidates</code><em> where the chosen numbers sum to </em><code>target</code><em>.</em> You may return the combinations i... | 3 | {
"code": "class Solution {\npublic:\n vector<vector<int>> combinationSum(vector<int>& candidates, int target) {\n\n vector<vector<int>> ans;\n vector<int> dp;\n solve(0, candidates, target, ans, dp);\n return ans;\n }\n\n void solve(int ind, vector<int> arr, int target, vector<ve... |
40 | <p>Given a collection of candidate numbers (<code>candidates</code>) and a target number (<code>target</code>), find all unique combinations in <code>candidates</code> where the candidate numbers sum to <code>target</code>.</p>
<p>Each number in <code>candidates</code> may only be used <strong>once</strong> ... | 0 | {
"code": "class Solution {\npublic:\n void combination(vector<int>& candidates, int target, vector<int> &valid, int currsum, int curridx,vector<vector<int>> &ans){\n if(currsum>target){\n return;\n }\n if(currsum==target){\n ans.push_back(valid);\n return;\n ... |
40 | <p>Given a collection of candidate numbers (<code>candidates</code>) and a target number (<code>target</code>), find all unique combinations in <code>candidates</code> where the candidate numbers sum to <code>target</code>.</p>
<p>Each number in <code>candidates</code> may only be used <strong>once</strong> ... | 0 | {
"code": "class Solution {\n public:\n vector<vector<int>> combinationSum2(vector<int>& candidates, int target) {\n vector<vector<int>> ans;\n ranges::sort(candidates);\n dfs(candidates, 0, target, {}, ans);\n return ans;\n }\n\n private:\n void dfs(const vector<int>& A, int s, int target, vector<int>... |
40 | <p>Given a collection of candidate numbers (<code>candidates</code>) and a target number (<code>target</code>), find all unique combinations in <code>candidates</code> where the candidate numbers sum to <code>target</code>.</p>
<p>Each number in <code>candidates</code> may only be used <strong>once</strong> ... | 0 | {
"code": " class Solution {\npublic:\n void sum(vector<vector<int>>& result, vector<int>& temp,\n vector<int>& candidates, int target, int start) {\n if (target == 0) {\n result.push_back(temp);\n return;\n }\n for (int i = start; i < candidates.size(); i++)... |
40 | <p>Given a collection of candidate numbers (<code>candidates</code>) and a target number (<code>target</code>), find all unique combinations in <code>candidates</code> where the candidate numbers sum to <code>target</code>.</p>
<p>Each number in <code>candidates</code> may only be used <strong>once</strong> ... | 0 | {
"code": "class Solution {\npublic:\n \n void helper(int index, vector<vector<int>>& ans,int target,vector<int>& temp,vector<int>& candidates)\n {\n if(target == 0)\n {\n ans.push_back(temp);\n return;\n }\n\n for(int i = index; i<candidates.size();i++)\n ... |
40 | <p>Given a collection of candidate numbers (<code>candidates</code>) and a target number (<code>target</code>), find all unique combinations in <code>candidates</code> where the candidate numbers sum to <code>target</code>.</p>
<p>Each number in <code>candidates</code> may only be used <strong>once</strong> ... | 2 | {
"code": "class Solution {\npublic:set<vector<int>>dp;\nvoid help(int idx,int tar,int n,vector<int>& candi,vector<int>& t)\n{\n if(tar==0)\n {\n dp.insert(t);\n return;\n }\n if(idx==n)\n return;\n for(int i=idx;i<n;i++)\n {\n if(tar<candi[i] )\n return;\n i... |
40 | <p>Given a collection of candidate numbers (<code>candidates</code>) and a target number (<code>target</code>), find all unique combinations in <code>candidates</code> where the candidate numbers sum to <code>target</code>.</p>
<p>Each number in <code>candidates</code> may only be used <strong>once</strong> ... | 2 | {
"code": "class Solution {\npublic:\nvoid generate(int ind,vector<int> &ds,set<vector<int>> &ans,vector<int>& candidates,int target){\n\t if(target==0){\n\t ans.insert(ds);\n return;\n\t }\n\t for(int i=ind;i<candidates.size();i++){\n if(i>ind && candidates[i]==candidates[i-1]) ... |
40 | <p>Given a collection of candidate numbers (<code>candidates</code>) and a target number (<code>target</code>), find all unique combinations in <code>candidates</code> where the candidate numbers sum to <code>target</code>.</p>
<p>Each number in <code>candidates</code> may only be used <strong>once</strong> ... | 2 | {
"code": "class Solution {\npublic:\nvoid solve(vector<int>& nums , int target , int i , vector<int>&temp ,set<vector<int>>&ans ){\n if( target == 0){\n ans.insert(temp); \n return ; \n }\n\n if(target < 0 || i >= nums.size()){\n return ; \n }\n\n if(nums[i] <= target ){\n ... |
40 | <p>Given a collection of candidate numbers (<code>candidates</code>) and a target number (<code>target</code>), find all unique combinations in <code>candidates</code> where the candidate numbers sum to <code>target</code>.</p>
<p>Each number in <code>candidates</code> may only be used <strong>once</strong> ... | 2 | {
"code": "class Solution {\npublic:\n vector<vector<int>>result;\n int n ,T; \n void solve(vector<int>&v,int sum ,int idx,vector<int>&cur)\n {\n if(sum>=T)\n {\n if(sum==T) result.push_back(cur);\n return;\n }\n \n if(idx==n)\n {\n ... |
40 | <p>Given a collection of candidate numbers (<code>candidates</code>) and a target number (<code>target</code>), find all unique combinations in <code>candidates</code> where the candidate numbers sum to <code>target</code>.</p>
<p>Each number in <code>candidates</code> may only be used <strong>once</strong> ... | 2 | {
"code": "class Solution {\npublic:\n vector<vector<int>> combinationSum2(vector<int>& candidates, int target) {\n sort(candidates.begin(), candidates.end());\n vector<vector<int>> ans;\n vector<int> t;\n function<void(int, int)> dfs = [&](int i, int s) {\n if (s == 0) {\n ... |
40 | <p>Given a collection of candidate numbers (<code>candidates</code>) and a target number (<code>target</code>), find all unique combinations in <code>candidates</code> where the candidate numbers sum to <code>target</code>.</p>
<p>Each number in <code>candidates</code> may only be used <strong>once</strong> ... | 2 | {
"code": "class Solution {\npublic:\n vector<vector<int>> combinationSum2(vector<int>& candidates, int target) {\n sort(candidates.begin(), candidates.end());\n vector<vector<int>> ans;\n vector<int> t;\n function<void(int, int)> dfs = [&](int i, int s) {\n if (s == 0) {\n ... |
40 | <p>Given a collection of candidate numbers (<code>candidates</code>) and a target number (<code>target</code>), find all unique combinations in <code>candidates</code> where the candidate numbers sum to <code>target</code>.</p>
<p>Each number in <code>candidates</code> may only be used <strong>once</strong> ... | 3 | {
"code": "class Solution {\npublic:\n vector<vector<int>> combinationSum2(vector<int>& candidates, int target) {\n sort(candidates.begin(), candidates.end());\n vector<vector<int>> ans;\n vector<int> t;\n function<void(int, int)> dfs = [&](int i, int s) {\n if (s == 0) {\n ... |
40 | <p>Given a collection of candidate numbers (<code>candidates</code>) and a target number (<code>target</code>), find all unique combinations in <code>candidates</code> where the candidate numbers sum to <code>target</code>.</p>
<p>Each number in <code>candidates</code> may only be used <strong>once</strong> ... | 3 | {
"code": "class Solution {\npublic:\n\n // void combinationSum2(unordered_map<<int,int>>& candidates, int target, std::unordered_map<std::int, int>::iterator iter, vector<int> &temp, vector<vector<int>> &res)\n void combinationSum2(std::unordered_map<int, int>& candidates, int target, std::unordered_map<int, i... |
40 | <p>Given a collection of candidate numbers (<code>candidates</code>) and a target number (<code>target</code>), find all unique combinations in <code>candidates</code> where the candidate numbers sum to <code>target</code>.</p>
<p>Each number in <code>candidates</code> may only be used <strong>once</strong> ... | 3 | {
"code": "class Solution {\npublic:\n set<vector<int>> S;\n vector<int> c;\n void getAll(vector<int> &candidates, int target, int i) {\n if(target == 0) {\n S.insert(c);\n return;\n }\n if(i == candidates.size() || target < 0) {\n return;\n }\n ... |
40 | <p>Given a collection of candidate numbers (<code>candidates</code>) and a target number (<code>target</code>), find all unique combinations in <code>candidates</code> where the candidate numbers sum to <code>target</code>.</p>
<p>Each number in <code>candidates</code> may only be used <strong>once</strong> ... | 3 | {
"code": "class Solution {\npublic:\n void AllCombination(int ind, vector<int> &nums, int target, vector<int> ans, vector<vector<int>> &result)\n {\n if(target == 0)\n {\n result.push_back(ans);\n return;\n }\n for(int i = ind; i < nums.size(); i++)\n {\n ... |
40 | <p>Given a collection of candidate numbers (<code>candidates</code>) and a target number (<code>target</code>), find all unique combinations in <code>candidates</code> where the candidate numbers sum to <code>target</code>.</p>
<p>Each number in <code>candidates</code> may only be used <strong>once</strong> ... | 3 | {
"code": "class Solution {\npublic:\nvoid solve(vector<int>& candidates, int target,set<vector<int>>&ans2,vector<int>out,int index){\n //base case\n if(target==0){\n ans2.insert(out);\n }\n for(int i =index;i<candidates.size();i++ ){\n if (i > index && candidates[i] == candidates[i - 1]) c... |
40 | <p>Given a collection of candidate numbers (<code>candidates</code>) and a target number (<code>target</code>), find all unique combinations in <code>candidates</code> where the candidate numbers sum to <code>target</code>.</p>
<p>Each number in <code>candidates</code> may only be used <strong>once</strong> ... | 3 | {
"code": "class Solution {\npublic:\n vector<vector<int>> combinationSum2(vector<int>& candidates, int target) {\n vector<vector<int>> res;\n vector<int> tmp_vec;\n sort(candidates.begin(),candidates.end());\n getPossiableCombine(res,candidates,target,tmp_vec,0);\n set<vector<in... |
40 | <p>Given a collection of candidate numbers (<code>candidates</code>) and a target number (<code>target</code>), find all unique combinations in <code>candidates</code> where the candidate numbers sum to <code>target</code>.</p>
<p>Each number in <code>candidates</code> may only be used <strong>once</strong> ... | 3 | {
"code": "#pragma GCC optimize(\"O3\", \"unroll-loops\")\nstatic const auto InitialOptimization = [](){\n ios_base::sync_with_stdio(false);\n cin.tie(0);\n cout.tie(0);\n return 0;\n}();\n\nclass Solution {\n size_t n;\n void backtracking(vector<vector<int>> &combinations, vector<int> &cur, size_t ... |
40 | <p>Given a collection of candidate numbers (<code>candidates</code>) and a target number (<code>target</code>), find all unique combinations in <code>candidates</code> where the candidate numbers sum to <code>target</code>.</p>
<p>Each number in <code>candidates</code> may only be used <strong>once</strong> ... | 3 | {
"code": "class Solution {\npublic:\n\n vector <int> cand;\n map< vector<int>, int > mp2;\n \n map<int, int> m;\n vector<vector<int>> ans;\n\n void recursion(int target, vector<int> &v, int index) {\n\n if (target < 0) {\n return;\n }\n\n for (int i = index; i < cand... |
40 | <p>Given a collection of candidate numbers (<code>candidates</code>) and a target number (<code>target</code>), find all unique combinations in <code>candidates</code> where the candidate numbers sum to <code>target</code>.</p>
<p>Each number in <code>candidates</code> may only be used <strong>once</strong> ... | 3 | {
"code": "class Solution {\npublic:\n\n vector <int> cand;\n map< vector<int>, int > mp2;\n \n map<int, int> m;\n vector<vector<int>> ans;\n\n void recursion(int target, vector<int> &v, int index) {\n\n if (target < 0) {\n return;\n }\n\n for (int i = index; i < cand... |
40 | <p>Given a collection of candidate numbers (<code>candidates</code>) and a target number (<code>target</code>), find all unique combinations in <code>candidates</code> where the candidate numbers sum to <code>target</code>.</p>
<p>Each number in <code>candidates</code> may only be used <strong>once</strong> ... | 3 | {
"code": "#pragma GCC optimize(\"O3\", \"unroll-loops\")\nstatic const auto InitialOptimization = [](){\n ios_base::sync_with_stdio(false);\n cin.tie(0);\n cout.tie(0);\n return 0;\n}();\n\nclass Solution {\n size_t n;\n void backtracking(vector<vector<int>> &combinations, vector<int> &cur, size_t ... |
40 | <p>Given a collection of candidate numbers (<code>candidates</code>) and a target number (<code>target</code>), find all unique combinations in <code>candidates</code> where the candidate numbers sum to <code>target</code>.</p>
<p>Each number in <code>candidates</code> may only be used <strong>once</strong> ... | 3 | {
"code": "class Solution {\n size_t n;\n void backtracking(vector<vector<int>> &combinations, vector<int> &cur, size_t i, int target,\n vector<int> &candidates) {\n if (target == 0) {\n combinations.push_back(cur);\n return;\n }\n if (i == n || ta... |
40 | <p>Given a collection of candidate numbers (<code>candidates</code>) and a target number (<code>target</code>), find all unique combinations in <code>candidates</code> where the candidate numbers sum to <code>target</code>.</p>
<p>Each number in <code>candidates</code> may only be used <strong>once</strong> ... | 3 | {
"code": "class Solution {\npublic:\n\nvoid helper(vector<int>& a, vector<vector<int>>&ans, vector<int>temp, int tgt, int idx){\n \n if(tgt==0){ // condition hit\n ans.push_back(temp);\n return;\n }\n for(int i= idx; i<a.size() ;i++){\n if(i!=idx && a[i]==a[i-1]) continu... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.