id int64 1 3.58k | problem_description stringlengths 516 21.8k | instruction int64 0 3 | solution_c dict |
|---|---|---|---|
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>> ans;\n int n;\n map<int,int> counter;\n void addcomb(map<int,int>::iterator it,vector<int> &res,int target){\n if(target == 0){\n ans.push_back(res);\n return;\n }\n if(it == counter.end() || target < 0)\... |
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:\nvector<vector<int>>ans;\nvector<int>a;\nvoid solve(int i , int t , int sum , vector<int>&c){\n if(sum==t){\n ans.push_back(a);\n return ;\n }\n if(i>= c.size() || sum>t) return;\n int in = upper_bound(c.begin() , c.end() ,c[i]) - c.begin();\n solve(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": "\n#define endl '\\n'\n#define pint pair<int, int>\n#define vint vector<int>\n#define vll vector<long long>\n#define vpint vector<pair<int, int>>\n#define vstr vector<string>\n#define uset unordered_set\n#define umap unordered_map\n#define vbool vector<bool>\n#define vvint vector<vector<int>>\n#define vvvin... |
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": "/*\n * @lc app=leetcode id=40 lang=cpp\n *\n * [40] Combination Sum II\n */\n\n// @lc code=start\nclass Solution\n{\npublic:\n vector<vector<int>> ans;\n void findsum(int j, int sum, vector<int> v, vector<int> &candidates, int target)\n {\n for (int i = j; 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> ... | 3 | {
"code": "class Solution {\npublic:\n bool dfs(int i,const vector<int>& candidates,int sum,const int& target,vector<int> currResult,vector<vector<int>>& result){\n sum+=candidates[i];\n if(sum>target){\n return false;\n }\n currResult.push_back(candidates[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:\n\n void combinationSumHelper(int& i,vector<int>& arr, int& target, vector<int>& curr, vector<vector<int>>& res){\n if(i == arr.size()){\n if(!target)\n res.push_back(curr);\n return;\n }\n int orgTarget = 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> ... | 3 | {
"code": "class Solution {\npublic:\n vector<vector<int>> ans;\n int n;\n void addcomb(int pos,vector<int> &res,vector<int>& candidates,int target){\n if(target == 0){\n ans.push_back(res);\n return;\n }\n if(pos == n)\n return;\n int j,count=0,va... |
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": "#include <algorithm>\n#include <climits>\n#include <functional>\n#include <iostream>\n#include <queue>\n#include <stack>\n#include <string>\n#include <unordered_map>\n#include <unordered_set>\n#include <vector>\n#pragma GCC optimize(\"O3,unroll-loops\")\n#pragma GCC target(\"avx2,bmi,bmi2,lzcnt,popcnt\")\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 {\n vector<vector<int>> ans;\n vector<int> curr;\n int t;\npublic:\n vector<vector<int>> combinationSum2(vector<int>& candidates, int target) {\n vector<int> freq(51,0);\n t = target;\n int maxm = candidates[0];\n for(int i=0;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> ... | 3 | {
"code": "class Solution {\n vector<vector<int>> ans;\n vector<int> v;\n void dfs(vector<int>& c,int t,int sum,int ind){\n if(sum > t){\n return;\n }\n if(ind > 50)\n return;\n if(sum == t){\n ans.push_back(v);\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 vector<vector<int>> ans = {};\n vector<int> cur = {};\n void rec(vector<int> candidates,int target, int i){\n if (target==0){\n ans.push_back(cur);\n return;\n }\n for (int j = i; j < candidates.size(); j++){\n if (j... |
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 subset(int i, int n, int target, vector<int> nums,\n vector<int>& vc, vector<vector<int>>& ans) {\n\n if (target == 0) {\n ans.push_back(vc);\n\n return;\n }\n\n for (int ind = i; ind < n; ind++) {\n if... |
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 /////////////////////// Consumes extra space ////////////////\n // void combination(int ind,vector<int> &temp,set<vector<int>> &ans,int target,vector<int> candidates){\n // if(ind>=candidates.size()){\n // if(target==0){\n // ans.insert(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 vector<vector<int>> ans = {};\n vector<int> cur = {};\n void rec(vector<int> candidates,int target, int i){\n if (target==0){\n ans.push_back(cur);\n return;\n }\n for (int j = i; j < candidates.size(); j++){\n if (j... |
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>> ans = {};\n vector<int> cur = {};\n void rec(vector<int> candidates,int target, int i){\n if (target==0){\n ans.push_back(cur);\n return;\n }\n for (int j = i; j < candidates.size(); j++){\n if (j... |
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>> ans;\n int n;\n void helper(int ele,vector<int> &v,int target,vector<int> &val){\n if(target==0){\n ans.push_back(val);\n return;\n }\n if(ele>target){\n return;\n }\n if(v[ele]>0){\... |
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 {\nprivate:\n void helper(vector<int>& candidates,int i, int target,vector<int>& freq, vector<int>& ds, vector<vector<int>> & ans) {\n if(0 == target) {\n ans.push_back(ds);\n return;\n }\n if(i >= freq.size() || target < 0) 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 vector<vector<int>> ans;\n void solve(int index, int left,vector<pair<int,int>> &v, vector<int> &temp)\n {\n if(left == 0)\n {\n ans.push_back(temp);\n return ;\n }\n else if(left < 0) return ;\n if(index >= v.siz... |
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 rec(int &n, int t, int i, vector<pair<int,int>>& cd, vector<vector<int>>& ans, vector<int>& v)\n {\n if(t<0) return;\n if(i>n-1)\n {\n if(t==0) ans.push_back(v);\n return;\n }\n int val = cd[i].first;\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 {\n vector<vector<int>>dp;\n int N;\n void hello(int pos,vector<int>&temp,int target,vector<int>a,vector<vector<int>>&ans){\n if(target==0){\n ans.push_back(temp);\n return;\n }\n // int &sm=dp[pos][target];\n // if(sm!=1){\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 struct Item {\n vector<int> combination;\n int sum;\n size_t index;\n\n Item(int initValue, size_t index) : sum(initValue), index(index) {\n combination.emplace_back(initValue);\n }\n\n void add(int value, size_t index) {... |
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>> ans;\n void dfs(int now, vector<int>& sans, int target, vector<int>& candidates, int pl){\n if(now==target){\n ans.push_back(sans);\n return;\n }\n if(now>target || pl>=candidates.size()) return;\n int 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 vector<vector<int>> tempAns;\n vector<vector<int>> combinationSum2(vector<int>& candidates, int target) \n {\n sort(candidates.begin(),candidates.end());\n vector<int> c;\n func(candidates,candidates.size(),target,c,0,0);\n vector<vector<int>> ans=tempAn... |
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\n int sum = 0;\n int index = 0;\n vector<int>temp = {};\n vector<vector<int>>answer;\n\n backtrack(temp,index,su... |
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": "# include <bits/stdc++.h>\nusing namespace std;\n\nclass Solution {\npublic:\n\n void printMap(unordered_map<int, int> &map) {\n cout << \"{\" <<endl;\n for (auto pair : map) {\n cout << pair.first << \" : \" << pair.second << \",\" << endl;\n }\n cout << \"}\" << ... |
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 findcombs(int ind,vector<vector<int>> &ans,vector<int> ds,int target,int n,vector<int> arr)\n {\n if(target==0)\n {\n ans.push_back(ds);\n return;\n }\n\n for(int i=ind;i<n;i++)\n {\n if(i>ind && arr[i]==arr[i-1]) continue;\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> ... | 3 | {
"code": "class Solution {\npublic:\nvector<vector<int>> ans;\n\nvoid solve(int i,int val,vector<int> a,vector<int> b){\n if(val==0){\n sort(b.begin(),b.end());\n ans.push_back(b);\n return;\n }\n else{\n for(int j=i;j<a.size();j++){\n if(j!=i && a[j]==a[j-1]) continue;\n if... |
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>> solve(vector<pair<int, int>>& v, int idx, int target) {\n vector<vector<int>> ret;\n if (target == 0) {\n ret = {{}};\n return ret;\n }\n else if (idx == v.size() || target < 0) {\n return ret;\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 help(int i,int k,vector<int> temp,vector<int> v,set<vector<int>> &res){\n if(k==0){\n sort(temp.begin(),temp.end());\n res.insert(temp);\n return;\n }\n for(int j=i; j<v.size(); j++){\n if(j>i&&v[j]==v[j-1]) co... |
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 set<vector<int>>pairs;\n vector<int>currPair;\n constructPairs(candidates , target , 0 , 0 , currPair , pairs);\n vec... |
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<int> new_cands;\n unordered_map<int, int> lookup;\n for_each(candidates.begin(), candidates.end(), [&](const int &val) {\n if (!lookup.contains(val)) {\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 struct Item {\n vector<int> combination;\n int sum;\n size_t index;\n size_t hash = 0;\n\n Item(int initValue, size_t index) : sum(initValue), index(index), hash(initValue*50) {\n combination.emplace_back(initValue);\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 vector<vector<int>> valid_subsets;\n\n std::sort(candidates.begin(), candidates.end());\n\n std::vector<bool> subset_bit_vector(candidates.size(), false);\n _combinationSu... |
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:\nvector<vector<int>> ans;\nmap<vector<int>,int> m;\nvoid calculateSum(vector<int> cand,int target,int i,vector<int> temp,int sum){\n if(target==sum){\n // sort(temp.begin(),temp.end());\n if(!m[temp])\n ans.push_back(temp);\n m[temp]++;\n retu... |
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>> dp[103][31];\n int dp_v[103][31];\n vector<vector<int>> solve(vector<pair<int, int>>& v, int idx, int target) {\n vector<vector<int>> ret;\n if (target == 0) {\n ret = {{}};\n return ret;\n }\n else 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 vector<vector<int>> dp[103][31];\n int dp_v[103][31];\n vector<vector<int>> solve(vector<pair<int, int>>& v, int idx, int target) {\n vector<vector<int>> ret;\n if (target == 0) {\n ret = {{}};\n return ret;\n }\n else 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 vector<vector<int>>ans;\n set<vector<int>>st;\n void rec(vector<int>&c, int t, int i, vector<int>&a,int pre){\n if(t==0){\n if(st.find(a)==st.end()){\n ans.push_back(a);\n st.insert(a);\n }\n return;\... |
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 fun( vector<vector<int>>&ans, vector<int>tmp, vector<int>&v,int t,int i){\n if(t==0){if(!tmp.empty())ans.push_back(tmp); return;}\n if(i==v.size())return;\n //take\n if(v[i]<=t){\n tmp.push_back(v[i]);\n fun(ans,tmp,v,t-v... |
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\n vector<vector<int>> ans;\n vector<int> curr;\n sort(candidates.begin(), candidates.end());\n combination(candidates, target, 0, curr, ans);\n return ans;\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\n void Csum(vector<int>& candidates,int i,int target,vector<int> ds,vector<vector<int>> &ans)\n {\n if(target==0)\n {\n ans.push_back(ds);\n return;\n }\n if(i>=candidates.size() || target<0)\n return;\n if(ca... |
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 // bool isSafe(vector<vector<int>>&result,vector<int>&combination){\n // for(int i=0; i<result.size(); i++){\n // if(result[i]==combination){\n // return false;\n // }\n // }\n // return true;\n // }\n void solve... |
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 solve(vector<int>&arr,int i,int sum,vector<int> temp,vector<vector<int>>& ans){\n if(sum<0) return;\n if(sum==0){\n ans.push_back(temp);\n return;\n }\n for(int it = i;it<arr.size();it++){\n if(it>i && arr[it]=... |
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 void helper(vector<int> &candidates, vector<int> res, set<vector<int>> &ans, int target, int ind){\n if(target == 0){\n ans.insert(res);\n return;\n }\n if(target < 0)return;\n if(ind >= candidates.size()){\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> ... | 3 | {
"code": "class Solution {\npublic:\n\n struct Item {\n vector<int> combination;\n int sum;\n size_t index;\n size_t hash = 0;\n\n Item(int initValue, size_t index) : sum(initValue), index(index), hash(initValue*50) {\n combination.emplace_back(initValue);\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 combination(vector<int>& candidates, int target, vector<vector<int>>& ans, vector<int>currComb, int index, int currSum){\n \n if(target<currSum){\n return;\n }\n if(currSum==target){\n ans.push_back(currComb);\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>> func(int freq[], int target, int val ){\n vector<vector<int>> ans;\n ans.clear();\n if(val > target){\n ans.clear();\n return ans;\n }\n if(freq[val] == 0) return func(freq, target, val+1);\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 struct Item {\n vector<int> combination;\n int sum;\n size_t index;\n size_t hash = 0;\n\n Item(int initValue, size_t index) : sum(initValue), index(index), hash(initValue*50) {\n combination.emplace_back(initValue);\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 rec(int idx, vector<vector<int>>&ans,vector<int>t,vector<int>& candidates,int target){\n if (target<0) return;\n\n if (target == 0){\n ans.push_back(t);\n }\n\n for (int i = idx;i<candidates.size();i++){\n if (i>idx && ca... |
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>> result;\n void solve(vector<int>& candidates, int target,int idx,vector<int> curr){\n if(target<0) return;\n if(target==0){\n result.push_back(curr);\n }\n for(int i=idx;i<candidates.size();i++){\n if(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 {\n vector<vector<int>> ans;\n int n;\n vector<int> c;\n void solve(int i, int tar, std::vector<int> temp){\n if(tar==0){\n ans.push_back(temp);\n }\n if(i>=n || tar<0) return;\n\n int prev=-1;\n for(int j =i; j<n; j++){\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 {\n vector<int> constructVector(unordered_map<int,int> &currFreq){\n vector<int> ans;\n for(auto it:currFreq){\n for(int i=0;i<it.second;i++){\n ans.push_back(it.first);\n }\n }\n sort(ans.begin(),ans.end());\n return... |
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": "void recursion(set<vector<int>>&sans,vector<int>&temp,vector<int>& f,int sum,int ind, int &target){\n if(sum==target){\n sans.insert(temp);\n return;\n }\n if(ind>30 || sum>target)return;\n \n vector<int>temp2=temp;\n\n for(int i=0;i<=f[ind];i++,temp.push_back(ind)){\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>& arr, int target) {\n \n map<int,int> mp;\n\n for( int v: arr) {\n mp[v] += 1;\n }\n\n vector< vector< vector<int> > > dp( target+1, vector< vector<int> >());\n\n dp[0].push_b... |
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()); // Step 1: Sort the candidates array\n return dfs(candidates, target, 0, 0, {});\n }\n\nprivate:\n vector<vector<int>> dfs(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> ... | 3 | {
"code": "class Solution {\npublic:\n vector<vector<int>> res;\n int n;\n void ans(vector<int>& candidates, int target, vector<int> subset, int i)\n {\n //cout<<candidates[i]<<\" \"<<target<<\" \"<<i<<\"-->\";\n if(target==0)\n {\n cout<<\"a\";\n res.push_back(s... |
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>> res;\n int n;\n void ans(vector<int>& candidates, int target, vector<int> subset, int i)\n {\n if(target==0)\n {\n res.push_back(subset);\n return;\n }\n if(i<0)\n {\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> ... | 3 | {
"code": "class Solution {\npublic:\n vector<vector<int>> res;\n int n;\n void ans(vector<int>& candidates, int target, vector<int> subset, int i)\n {\n if(target==0)\n {\n res.push_back(subset);\n return;\n }\n if(i<0)\n {\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> ... | 3 | {
"code": "class Solution {\npublic:\n vector<vector<int>> res;\n int n;\n void ans(vector<int>& candidates, int target, vector<int> subset, int i)\n {\n if(target==0)\n {\n res.push_back(subset);\n return;\n }\n if(i<0)\n {\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> ... | 3 | {
"code": "#include <vector>\n#include <set>\n#include <unordered_map>\n#include <algorithm>\n\nclass Solution {\npublic:\n int n;\n std::set<std::vector<int>> st; // To store unique combinations\n\n void find(int ind, std::vector<int>& candidates, int t, std::unordered_map<int, int>& mp, std::vector<int>& 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 unordered_set<string> found;\n\n vector<vector<int>> combinationSum2(vector<int>& candidates, int target) {\n vector<vector<int>> result;\n unordered_set<string> visited;\n\n found.clear();\n std::sort(candidates.begin(), candidates.end());\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>> ans;\n void solve(int idx, int target, vector<bool> vis, vector<int>& candidates){\n if(target < 0) return;\n if(!target){\n vector<int>cur;\n for(int i = 0; i < vis.size(); i++){\n if(vis[i]) cur.push_... |
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{\n\tpublic:\n\t\tstd::vector<std::vector<int>> combinationSum2(std::vector<int> &candidates, int target, int i = -1,\n\t\t\tstd::vector<std::vector<int>> *combinations = nullptr, std::vector<int> *combination = nullptr)\n\t\t{\n\t\t\tif (i == -1)\n\t\t\t{\n\t\t\t\tstd::sort(candidates.begi... |
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{\n\tpublic:\n\t\tstd::vector<std::vector<int>> combinationSum2(std::vector<int> &candidates, int target, int i = -1,\n\t\t\tstd::vector<std::vector<int>> *combinations = nullptr, std::vector<int> *combination = nullptr)\n\t\t{\n\t\t\tif (i == -1)\n\t\t\t{\n\t\t\t\tstd::sort(candidates.begi... |
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<vector<int>>> dp(target + 1);\n dp[0] = {{}};\n\n for (int c : candidates) {\n for (int i = target; ... |
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 sol(vector<int>& candidates, int target, int i, vector<vector<int>>&ans, vector<int>curr ){\n \n if(target == 0){\n ans.push_back(curr);\n return;\n }\n\n if (i >= candidates.size()){\n return;\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> ... | 3 | {
"code": "class Solution {\npublic:\n unordered_map<int, unordered_map<int, vector<vector<int>>>> UM;\n vector<vector<int>> R(vector<int>& O, vector<int>& F, int idx, int target) {\n if (idx < 0) {\n return vector<vector<int>>(target == 0);\n }\n if (UM[idx].find(target) != UM[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 unordered_map<int, unordered_map<int, vector<vector<int>>>> UM;\n vector<vector<int>> R(vector<int>& O, vector<int>& F, int idx, int target) {\n if (idx < 0) {\n return vector<vector<int>>(target == 0);\n }\n if (UM[idx].find(target) != UM[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 // map<pair<int,int>, vector<vector<int> > > dp;\n\n // vector<vector<int> > solve(int index, int target, vector<int>& candidates)\n // {\n // if(target==0) vector<vector<int> > ();\n // if(target<0) return vector<vector<int> > ();\n // if(index==ca... |
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 fun(int ind, int target, vector<int>& candidates,\n vector<vector<int>>& ans, vector<int> v) {\n\n if (target == 0) {\n ans.push_back(v);\n return;\n }\n if (target < 0)\n return;\n if (ind < 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 void util(vector<vector<int>>& ans,\n vector<int> temp,\n vector<int>& ct, \n int target, \n int cursum, \n int curind)\n {\n if(cursum > target)\n return;\n if(cursum == 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 void search(int cur,vector<int> vec,vector<vector<int>>& result,int tar,vector<int> count)\n {\n if(cur>tar) cur = tar;\n if(count[cur]==0){\n for(;count[cur]==0&&cur>0;cur--);\n }\n if(cur==0) return;\n\n search(cur-1,vec,resu... |
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>> getAns(int i,vector<int> temp,int target,vector<int> &candidates,vector<vector<int>> &finalAns){\n int n = candidates.size();\n if(target == 0){\n finalAns.push_back(temp);\n return finalAns;\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> ... | 3 | {
"code": "class Solution {\npublic:\nvector< vector<int> > ans;\n\nvoid func(vector<int>& x, int n,int target,vector<int> v)\n{\n if(target==0) \n {\n ans.push_back(v);\n return;\n }\n if(target<0||n<=0)\n return;\n v.push_back(x[n-1]);\n func(x,n-1,target-x[n-1],v);\n v.pop_bac... |
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>> out;\n vector<vector<int>> fin;\n\n vector<vector<int>> combinationSum2(vector<int>& candidates, int target) {\n sort(candidates.begin(), candidates.end(), greater<int>());\n \n if(checkPossible(candidates, 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> ... | 3 | {
"code": "class Solution {\npublic:\n void allCombToSum(vector<int> candidates, vector<vector<int>>& ans, vector<int>& comb, int idx, int target)\n {\n \n // BASE CASE 1\n if (target == 0)\n {\n ans.push_back(comb);\n return;\n }\n \n // BA... |
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>> out;\n vector<vector<int>> fin;\n\n vector<vector<int>> combinationSum2(vector<int>& candidates, int target) {\n sort(candidates.begin(), candidates.end(), greater<int>());\n \n // if(checkPossible(candidates, 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> ... | 3 | {
"code": "class Solution {\n vector<vector<int>> solve(vector<int>& candidates, int target, int idx) {\n if (target == 0) {\n return {{}};\n }\n if (idx < 0 || target < 0) {\n return {};\n }\n\n vector<vector<int>> res;\n \n int x = idx-1;\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>& nums, int target) {\n int n=nums.size(),mx=0;\n sort(nums.begin(),nums.end());\n vector<vector<vector<int>>>prevdp(target+1),curdp(target+1);\n map<vector<int>,int>mp;\n for(int j=0;j<n;j++)\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 set<vector<int>> out;\n // vector<vector<int>> fin;\n\n vector<vector<int>> combinationSum2(vector<int>& candidates, int target) {\n sort(candidates.rbegin(), candidates.rend());\n \n // if(checkPossible(candidates, target)) {\n gen(0, 0,... |
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 solve(int ind, vector<int> &ds,vector<int>& candidates,int sum, int target\n ,vector<vector<int>>&ans )\n {\n if(sum==target)\n {\n ans.push_back(ds);\n return;\n }\n if(sum... |
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>> out;\n vector<vector<int>> fin;\n\n vector<vector<int>> combinationSum2(vector<int>& candidates, int target) {\n sort(candidates.rbegin(), candidates.rend());\n \n // if(checkPossible(candidates, target)) {\n gen(0, 0,... |
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 recursion (int i,int n ,vector<int>&candidates, int target,vector<int>&temp,vector<vector<int>>&res)\n {\n if(target==0)\n {\n res.push_back(temp);\n return;\n }\n\n if(target<0)\n return;\n\n if(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> ... | 3 | {
"code": "class Solution {\npublic:\n void combination(vector<vector<int>>& ans, vector<int>& ds,vector<int> nums,int i,int s,int n, int target) {\n if(s == target) {\n ans.push_back(ds);\n }\n for(int k = i;k < n;k++) {\n if( k != i && nums[k] == nums[k-1]) continue;\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 combination(vector<vector<int>>& ans, vector<int>& ds,vector<int> nums,int i,int s,int n, int target) {\n if(s == target) {\n ans.push_back(ds);\n }\n for(int k = i;k < n;k++) {\n if( k != i && nums[k] == nums[k-1]) continue;\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 final_ans(vector<vector<int>> &ans, vector<int> &temp, int target, int i, int n, vector<int> c){\n if(target==0){\n ans.push_back(temp);\n return;\n }\n for(int r=i;r<n;r++){\n if (r>i && c[r]==c[r-1])\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 backtrack(vector<vector<int>>& sol, vector<int> cursol, int target, int cursum, int ind, vector<int>& counts) {\n if (cursum == target) {\n sol.push_back(cursol);\n return;\n }\n if (ind == target+1) return;\n for (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 void backtrack(vector<vector<int>>& sol, vector<int> cursol, int target, int cursum, int ind, vector<int>& counts) {\n if (cursum == target) {\n sol.push_back(cursol);\n return;\n }\n if (ind == target+1) return;\n if (cursum ... |
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>> combination(int i, int n, vector<int> candidates,\n vector<vector<int>>& ans, vector<int>& curr,\n int target) {\n if (target == 0) {\n ans.push_back(curr);\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 findSubsets(vector<int>v,int s, int idx, int t,vector<int>&a, vector<vector<int>>&ans)\n {\n if(s==t)\n {\n if(find(ans.begin(),ans.end(),a)==ans.end())\n ans.push_back(a);\n return;\n }\n int n=v.size()... |
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>> func(vector<int> cand, int ind, int tar, vector<vector<int>> &ans, vector<int> &comb){\n // Base case: If the target becomes zero, we've found a valid combination\n if (tar == 0) {\n ans.push_back(comb); // Add the current combina... |
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 recurse_ans(vector<int>& candidates, map<int ,int>& um, set<map<int, int>>& s, int cur_sum, const int target, int ind, bool prev_inc) {\n if (ind >= candidates.size() || cur_sum > target) {\n return;\n }\n recurse_ans(candidates, um, s, cu... |
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 {\nprivate:\n void solve(int index,vector<int> &cand,int n,int t,vector<int> temp,vector<vector<int>> &ans){\n //base case\n if(t==0){\n ans.push_back(temp);\n return;\n }\n\n if(index>=n)\n return;\n\n unordered_map<int,int> v... |
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 {\nprivate:\n vector<vector<int>> res;\npublic:\n vector<vector<int>> combinationSum2(vector<int>& candidates, int target) {\n \n sort(candidates.begin(), candidates.end());\n int last = 0;\n\n for (int i = 0; i < candidates.size(); ++i) {\n if (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 void helper(vector<int> candidates,int target,vector<vector<int>>& combs,int level,vector<int> tmp){\n if(target == 0){\n combs.push_back(tmp);\n return;\n }\n else if(level == candidates.size()){\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 helper(vector<int> candidates,int target,vector<vector<int>>& combs,int level,vector<int> tmp){\n if(target == 0){\n combs.push_back(tmp);\n return;\n }\n else if(level == candidates.size()){\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 helper(vector<int> candidates,int target,vector<vector<int>>& combs,int level,vector<int> tmp){\n if(target == 0){\n combs.push_back(tmp);\n return;\n }\n else if(level == candidates.size()){\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 combinationSumHelper(vector<int>& candidates, int& target, vector<int> nums, set<vector<int>>& ans, int index) {\n int sum = accumulate(nums.begin(), nums.end(), 0);\n if(sum == target) {\n sort(nums.begin(), nums.end());\n ans.insert(... |
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 combinationsum2(vector<pair<int,int>>& pcandidates, int target, int i, vector<int>ds,vector<vector<int>>& subset){\n//base case\nif(target==0){subset.push_back(ds);return ;}\nif(i==pcandidates.size()){return ;}\n\n//nottake\ncombinationsum2(pcandidates,target,i+1,ds,subset);... |
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 combinationSolver {\nprivate:\n const vector<int> candidates;\n unordered_map<int, int> candidates_freq;\n\n unordered_map<int, int> freq_map(const vector<int>& candidates) const {\n unordered_map<int, int> ans;\n for (const int& candidate : candidates) {\n if (ans.f... |
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 func(int i,long sum,int target,unordered_map<int,int>&mp, vector<int>& candidates,vector<vector<int>>& ans,vector<int> temp){\n int n=candidates.size();\n if(i==n){\n if(sum==target){\n ans.push_back(temp);\n }\n ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.