id
int64
1
3.58k
problem_description
stringlengths
516
21.8k
instruction
int64
0
3
solution_c
dict
516
<p>Given a string <code>s</code>, find <em>the longest palindromic <strong>subsequence</strong>&#39;s length in</em> <code>s</code>.</p> <p>A <strong>subsequence</strong> is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements.</p> <...
1
{ "code": "class Solution {\npublic:\n\n int hehe(int i,int j,string &s,vector<vector<int>>& dp){\n if(j<i) return 0;\n if(i==j) return 1;\n\n if(dp[i][j]!=-1) return dp[i][j];\n if(s[i]==s[j]){\n return 2+hehe(i+1,j-1,s,dp);\n }\n else{\n return dp[i...
516
<p>Given a string <code>s</code>, find <em>the longest palindromic <strong>subsequence</strong>&#39;s length in</em> <code>s</code>.</p> <p>A <strong>subsequence</strong> is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements.</p> <...
1
{ "code": "class Solution {\npublic:\n int find(string &s, vector<vector<int>> &dp, int start, int end) {\n if(start == end) return 1;\n if(start>end) return 0;\n if(dp[start][end] != -1) return dp[start][end];\n if(s[start] == s[end]) {\n dp[start][end] = 2+find(s, dp, start...
516
<p>Given a string <code>s</code>, find <em>the longest palindromic <strong>subsequence</strong>&#39;s length in</em> <code>s</code>.</p> <p>A <strong>subsequence</strong> is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements.</p> <...
1
{ "code": "class Solution {\npublic:\n int longestPalindromeSubseq(string s) {\n /*\n from/to c b b d\n c 1 1 2 2\n b 1 2 2\n b 1 1\n d 1\n \n \n */\n int n = s.size();\n vector<vector<int>> dp(n, vector<int...
516
<p>Given a string <code>s</code>, find <em>the longest palindromic <strong>subsequence</strong>&#39;s length in</em> <code>s</code>.</p> <p>A <strong>subsequence</strong> is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements.</p> <...
1
{ "code": "class Solution {\npublic:\n vector<vector<int>> dp;\n //dp[i][j] : lens of subsequence\n int f(int i,int j,string& s)\n {\n if(i == j)//only one char\n return 1;\n else if(j - i == 1) // two char\n return ((s[i] == s[j]) ? 2 : 1);\n else if(dp[i][j] !=...
516
<p>Given a string <code>s</code>, find <em>the longest palindromic <strong>subsequence</strong>&#39;s length in</em> <code>s</code>.</p> <p>A <strong>subsequence</strong> is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements.</p> <...
1
{ "code": "class Solution {\npublic:\n int solve(string &s, int i, int j){\n if(i>j) return 0;\n if(i == j) return 1;\n\n int ans = 0;\n if(s[i] == s[j]){\n ans = 2 + solve(s, i+1,j-1);\n }\n else{\n ans = max(solve(s, i+1, j), solve(s, i, j-1));\n ...
516
<p>Given a string <code>s</code>, find <em>the longest palindromic <strong>subsequence</strong>&#39;s length in</em> <code>s</code>.</p> <p>A <strong>subsequence</strong> is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements.</p> <...
1
{ "code": "class Solution {\npublic:\n int longestPalindromeSubseq(string s) {\n int n = s.size();\n string t = s;\n reverse(t.begin(),t.end());\n\n vector<vector<int>>dp(n+1,vector<int>(n+1,0));\n\n for(int i=1;i<=n;i++)\n {\n for(int j=1;j<=n;j++)\n ...
516
<p>Given a string <code>s</code>, find <em>the longest palindromic <strong>subsequence</strong>&#39;s length in</em> <code>s</code>.</p> <p>A <strong>subsequence</strong> is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements.</p> <...
2
{ "code": "class Solution {\npublic:\n int memo(string &s1, string &s2, int i, int j, vector<vector<int>> &dp){\n if(i<0 || j<0) return 0;\n if(dp[i][j] != -1) return dp[i][j];\n if(s1[i] == s2[j]) return dp[i][j] = 1 + memo(s1, s2, i-1, j-1, dp);\n return dp[i][j] = max(memo(s1, s2, i-...
516
<p>Given a string <code>s</code>, find <em>the longest palindromic <strong>subsequence</strong>&#39;s length in</em> <code>s</code>.</p> <p>A <strong>subsequence</strong> is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements.</p> <...
2
{ "code": "class Solution {\npublic:\n\n int f(int i,int j,string &s,vector<vector<int>>& dp){\n if(j<i) return 0;\n if(i==j) return 1;\n\n if(dp[i][j]!=-1) return dp[i][j];\n if(s[i]==s[j]){\n return 2+f(i+1,j-1,s,dp);\n }\n else{\n return dp[i][j]=m...
517
<p>You have <code>n</code> super washing machines on a line. Initially, each washing machine has some dresses or is empty.</p> <p>For each move, you could choose any <code>m</code> (<code>1 &lt;= m &lt;= n</code>) washing machines, and pass one dress of each washing machine to one of its adjacent washing machines at t...
0
{ "code": "class Solution \n{\npublic:\n int findMinMoves(vector<int>& machines) \n {\n int sum = 0;\n int n = machines.size();\n int difference = 0;\n for (int a : machines) sum+=a;\n if (sum % n != 0) return -1;\n int goal = sum/n;\n cout << \"goal: \" << goal ...
517
<p>You have <code>n</code> super washing machines on a line. Initially, each washing machine has some dresses or is empty.</p> <p>For each move, you could choose any <code>m</code> (<code>1 &lt;= m &lt;= n</code>) washing machines, and pass one dress of each washing machine to one of its adjacent washing machines at t...
0
{ "code": "class Solution {\npublic:\n\n int findMinMoves(vector<int>& machines) {\n int sum=0;\n for(auto ele:machines)sum+=ele;\n int n=machines.size();\n if(sum%n!=-0)return -1;\n int z=sum/n;\n int ans=0;\n int temp=0;\n for(auto ele:machines){\n ...
517
<p>You have <code>n</code> super washing machines on a line. Initially, each washing machine has some dresses or is empty.</p> <p>For each move, you could choose any <code>m</code> (<code>1 &lt;= m &lt;= n</code>) washing machines, and pass one dress of each washing machine to one of its adjacent washing machines at t...
0
{ "code": "class Solution {\npublic:\n\n int findMinMoves(vector<int>& machines) {\n int sum=0;\n for(auto ele:machines)sum+=ele;\n int n=machines.size();\n if(sum%n!=-0)return -1;\n int z=sum/n,ans=0,temp=0;\n for(auto ele:machines){\n temp+=ele-z;\n ...
517
<p>You have <code>n</code> super washing machines on a line. Initially, each washing machine has some dresses or is empty.</p> <p>For each move, you could choose any <code>m</code> (<code>1 &lt;= m &lt;= n</code>) washing machines, and pass one dress of each washing machine to one of its adjacent washing machines at t...
0
{ "code": "class Solution {\npublic:\n int findMinMoves(vector<int>& ms) {\n int n = ms.size();\n int sum = 0;\n for (int &i : ms) sum += i;\n if (sum % n) return -1;\n int t = sum / n;\n int ans = 0, toRight = 0;\n for (int &i : ms) {\n toRight = toRight...
517
<p>You have <code>n</code> super washing machines on a line. Initially, each washing machine has some dresses or is empty.</p> <p>For each move, you could choose any <code>m</code> (<code>1 &lt;= m &lt;= n</code>) washing machines, and pass one dress of each washing machine to one of its adjacent washing machines at t...
0
{ "code": "class Solution {\n public:\n int findMinMoves(vector<int>& machines) {\n const int dresses = accumulate(machines.begin(), machines.end(), 0);\n if (dresses % machines.size() != 0)\n return -1;\n\n int ans = 0;\n int inout = 0;\n const int average = dresses / machines.size();\n\n for...
517
<p>You have <code>n</code> super washing machines on a line. Initially, each washing machine has some dresses or is empty.</p> <p>For each move, you could choose any <code>m</code> (<code>1 &lt;= m &lt;= n</code>) washing machines, and pass one dress of each washing machine to one of its adjacent washing machines at t...
0
{ "code": "class Solution {\npublic:\n int findMinMoves(vector<int>& machines) {\n int total = accumulate(machines.begin(), machines.end(), 0);\n int n = machines.size();\n \n // Если общее количество платьев не делится на количество машин, решение невозможно\n if (total % n != 0...
517
<p>You have <code>n</code> super washing machines on a line. Initially, each washing machine has some dresses or is empty.</p> <p>For each move, you could choose any <code>m</code> (<code>1 &lt;= m &lt;= n</code>) washing machines, and pass one dress of each washing machine to one of its adjacent washing machines at t...
2
{ "code": "class Solution {\npublic:\n int findMinMoves(vector<int>& a) {\n int n = a.size();\n int sum = 0;\n for(int i =0;i<n;++i) sum+=a[i];\n if(sum%n!=0) return -1;\n int avg = sum/n;\n int ans = 0,cum=0,curr=0;\n for(int i = 0;i<n;++i){\n curr = a[i]...
517
<p>You have <code>n</code> super washing machines on a line. Initially, each washing machine has some dresses or is empty.</p> <p>For each move, you could choose any <code>m</code> (<code>1 &lt;= m &lt;= n</code>) washing machines, and pass one dress of each washing machine to one of its adjacent washing machines at t...
3
{ "code": "class Solution {\npublic:\n int findMinMoves(vector<int>& machines) {\n\n int sum = 0;\n for(int x: machines){\n sum += x;\n }\n if(sum % machines.size() != 0) return -1;\n\n int target = sum / machines.size();\n int left = 0;\n vector<int> dif...
517
<p>You have <code>n</code> super washing machines on a line. Initially, each washing machine has some dresses or is empty.</p> <p>For each move, you could choose any <code>m</code> (<code>1 &lt;= m &lt;= n</code>) washing machines, and pass one dress of each washing machine to one of its adjacent washing machines at t...
3
{ "code": "class Solution {\npublic:\n int findMinMoves(vector<int>& machines) {\n int n=machines.size();\n int total=accumulate(machines.begin(),machines.end(),0);\n if(total%n!=0) return -1;\n vector<int> prefix(n+1,0);\n for(int i=0;i<n;i++) prefix[i+1]=machines[i]+prefix[i];\...
517
<p>You have <code>n</code> super washing machines on a line. Initially, each washing machine has some dresses or is empty.</p> <p>For each move, you could choose any <code>m</code> (<code>1 &lt;= m &lt;= n</code>) washing machines, and pass one dress of each washing machine to one of its adjacent washing machines at t...
3
{ "code": "class Solution {\npublic:\n\n int max_sub(vector<int> &arr){\n int n = arr.size();\n vector<int> pref(n+1, 0);\n vector<int> suf(n+1, 0);\n int maxp=INT_MIN,maxs=INT_MIN,minp=INT_MAX,mins=INT_MAX;\n\n for(int i=0;i<n;i++){\n pref[i+1] = pref[i]+arr[i];\n ...
517
<p>You have <code>n</code> super washing machines on a line. Initially, each washing machine has some dresses or is empty.</p> <p>For each move, you could choose any <code>m</code> (<code>1 &lt;= m &lt;= n</code>) washing machines, and pass one dress of each washing machine to one of its adjacent washing machines at t...
3
{ "code": "class Solution {\npublic:\n int findMinMoves(vector<int>& machines) {\n int n = machines.size();\n int sum = 0;\n for(int i=0;i<n;i++){\n sum += machines[i];\n }\n if(sum%n != 0){\n return -1;\n }\n\n int x = sum/n;\n\n vector...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "class Solution {\npublic:\n int change(int amount, vector<int>& coins) {\n /* space optimized dp */\n\n int dp[amount + 1];\n memset(dp, 0, sizeof dp);\n\n dp[0] = 1;\n\n for(auto& coin : coins)\n for(int sum = coin; sum <= amount; sum++)\n dp...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "class Solution {\n int dp[5003];\npublic:\n int change(int amount, vector<int>& coins) {\n dp[0] = 1;\n\n for(auto coin : coins) {\n for(int i=1;i<=amount;i++) {\n if (coin <= i) {\n dp[i] += dp[i - coin];\n }\n }\n ...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "class Solution {\npublic:\n int change(int amount, vector<int>& coins) \n {\n vector<int> dp(amount+1, 0);\n dp[0]=1;\n \n for(auto& coin: coins)\n {\n for(int i=coin;i<=amount;i++)\n dp[i]+=dp[i-coin];\n }\n\n return dp[amoun...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "class Solution {\npublic:\n int change(int amount, vector<int>& coins) {\n \n vector<int> dp(amount + 1, 0);\n dp[0] = 1;\n\n for(int num : coins){\n for(int i = 1; i <= amount; i++){\n if(i - num < 0) continue;\n dp[i] += dp[i - num];...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "class Solution {\npublic:\n int change(int amount, vector<int>& coins) {\n vector<int> dp(amount+1);\n dp[0]=1;\n for(auto it:coins)\n {\n for(int i=it;i<=amount;i++)\n {\n dp[i]+=dp[i-it];\n }\n }\n\n return dp[am...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "class Solution {\npublic:\n int change(int amount, vector<int>& coins) {\n std::sort(coins.begin(), coins.end());\n vector<int> dp(amount+1, 0);\n dp[0] = 1;\n\n for (const int &i : coins) {\n\n for (int x = i; x <= amount; x++) {\n dp[x] += dp[x-i];...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "class Solution {\npublic:\n int memo(int idx, int sum, int amount, vector<int>& coins, vector<vector<int>>& dp){\n if(idx == 0) return !((amount - sum) % coins[0]);\n if(dp[idx][sum] != -1) return dp[idx][sum];\n\n int take = 0, notTake = memo(idx - 1, sum, amount, coins, dp);\n ...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "class Solution {\npublic:\n int memo(int idx, int sum, int amount, vector<int>& coins, vector<vector<int>>& dp){\n if(idx == 0) return !((amount - sum) % coins[0]);\n if(dp[idx][sum] != -1) return dp[idx][sum];\n\n int take = 0, notTake = memo(idx - 1, sum, amount, coins, dp);\n ...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "class Solution {\npublic:\n int change(int amount, vector<int>& coins) {\n /*\n DP[i][a]: # of combos to get to a that uses coins[<=i].coins[i] may or may not in there. \n \n - Combos that have coins[i], we remove it\n if (a - coins[i] >= 0)\n = DP[i][a ...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "class Solution {\npublic:\n vector<int> coins;\n int n;\n\n vector<vector<int>> memo;\n\n long long c(int i, int target) {\n if (target == 0) return 1;\n if (i == n) return 0;\n if (memo[i][target] != -1) return memo[i][target];\n\n long long res = 0;\n res +=...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "class Solution {\npublic:\n int change(int amount, vector<int>& coins) {\n auto const max_amount = 5000;\n std::vector<uint64_t> ways(max_amount + 1, 0);\n\n ways[0] = 1;\n\n for(auto const& coin: coins) {\n for(int i=0; i<=max_amount-coin; ++i) {\n ...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "class Solution {\npublic:\n int change(int t, vector<int>& v) {\n\n vector<long>dp(5001,0);\n dp[0]=1;\n for(auto i: v){\n for(int j=0;j<=5000;j++){\n if(j+i<=5000) dp[j+i]+=dp[j];\n }\n }\n return dp[t];\n \n }\n};", "m...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "class Solution {\npublic:\n int change(int amount, vector<int>& coins) {\n int dp[1000000]; //set dp mean amount=i have dp[i] kinds of combination;\n memset(dp,0,sizeof(dp));\n dp[0] =1;\n\n for(auto c: coins){\n for(int i=1;i<=amount;i++){\n if(i-c>...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "class Solution {\npublic:\n int change(int amount, vector<int>& coins) \n {\n int n = coins.size();\n int dp[n+1][amount+1];\n // if amount is 0\n for(int i=0; i<=n; i++)\n {\n dp[i][0] = 1;\n }\n // if coins are zero except (0,0)\n f...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "class Solution {\npublic:\n int change(int amount, vector<int>& coins) {\n int dp[coins.size()][amount+1];\n memset(dp,0,sizeof(dp));\n for(int i=0;i<=amount;i++) {\n if(i%coins[0]==0){\n dp[0][i]=1;\n }\n }\n for(int i=1;i<coins.si...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "class Solution {\npublic:\n int change(int amount, vector<int>& coins){\n int number_of_coins = coins.size();\n int dp[number_of_coins+1][amount+1];\n\n for(int i=0; i<=number_of_coins; i++){\n for (int j=0; j<=amount; j++){\n if (i==0 && j==0){\n dp[i][i]=0;\n ...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "class Solution {\npublic:\n int change(int amount, vector<int>& coins) {\n vector<int> dp(amount+1,0);\n dp[0]=1;\n // for(int j=0;j<coins.size();j++){\n // dp[coins[j]]=1;\n // }\n int n=coins.size();\n int t[n+1][amount+1];\n\n for(int i=...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "class Solution {\npublic:\n int change(int amount, vector<int>& coins) {\n vector<int> dp(amount+1,0);\n dp[0]=1;\n // for(int j=0;j<coins.size();j++){\n // dp[coins[j]]=1;\n // }\n int n=coins.size();\n int t[n+1][amount+1];\n\n for(int i=...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "int dp[302][5002];\n\n// int rec(int level,int left,vector<int>& coins){\n\n// if(level == n){\n// if(left == 0) return 1;\n// else return 0;\n// }\n\n// if(dp[level][left]!=-1) return dp[level][left];\n// int take = 0;\n// if(left >= coins[level]){\n// take = re...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "const int MAX_N = 300 + 1;\nconst int MAX_T = 5000 + 1;\nint memory[MAX_N][MAX_T];\n\n\n\nclass Solution {\n vector<int> numbers;\npublic:\n\n int change_rec(int amount, vector<int> &coins) {\n numbers = coins;\n memset(memory, -1, sizeof(memory));\n return change(amount, coins);...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "int t[301][5002];\nclass Solution {\npublic:\n Solution()\n {\n memset(t,-1,sizeof(t));\n }\n int getans(vector<int>&coins,int amount,int n)\n {\n if(amount==0)\n return 1;\n if(n==0||amount<0)\n return 0;\n if(t[n][amount]!=-1)\n ...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "int dp[301][5001];\n\nint rec(int level,int left,vector<int>& coins){\n\n if(level < 0){\n if(left == 0) return 1;\n else return 0;\n }\n\n if(dp[level][left]!=-1) return dp[level][left];\n int take = 0;\n if(left >= coins[level]){\n take = rec(level,left-coins[level],co...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "int dp[301][5001];\nclass Solution {\npublic:\nint fun(int id,int amount,vector<int>&coins)\n{\n if(amount==0)\n {\n return 1;\n }\n if(id>=coins.size()||amount<0)\n {\n return 0;\n }\n if(dp[id][amount]!=-1)\n {\n return dp[id][amount];\n }\n int nottake=...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "class Solution {\npublic:\nint dp[300][5001];\n int change(int amount, vector<int>& coins) {\n memset(dp,-1,sizeof(dp));\n return func(0,amount,coins);\n }\n\n int func(int i,int amount, vector<int>& coins)\n {\n if(amount==0) return 1;\n if(i==coins.size()) return 0...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "class Solution {\npublic:\n int change(int amount, vector<int>& coins) {\n int dp[5001][301] = {0}, n = coins.size();\n\n dp[0][0] = 1;\n\n for (int i = 0; i <= amount; i++) {\n for (int j = 1; j <= n; ++j) {\n dp[i][j] = dp[i][j - 1];\n int ...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "class Solution {\npublic:\n int change(int amount, vector<int>& coins) {\n int dp[301][5001] = {0}, n = coins.size();\n\n dp[0][0] = 1;\n\n for (int i = 0; i <= amount; i++) {\n for (int j = 1; j <= n; ++j) {\n dp[j][i] = dp[j - 1][i];\n int ...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "class Solution {\npublic:\n int change(int amount, vector<int>& coins) {\n\n int dp[300+1][5000+1];\n memset(dp, 0, sizeof(dp));\n\n for(int i =0; i <= coins.size(); i++)\n {\n for(int j =0; j <= amount;j++)\n {\n if(j==0)\n dp[i][j] = 1;\n ...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "class Solution {\npublic:\nint dp[305][5005];\nint fn(int k,vector<int>&a,int i){\n if(i<=0||k<0)return 0;\n if(dp[i][k]!=-1)return dp[i][k];\n if(k==0)return 1;\n int p=fn(k-a[i-1],a,i);\n int q=fn(k,a,i-1);\n return dp[i][k]=p+q;\n}\n int change(int k, vector<int>& a) {\n mems...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "class Solution {\npublic:\n\n int dp[5001][301];\n\n int helper(int amount,int pos, vector<int> &coins){\n if(amount<0) return 0;\n if(pos==0){\n return !(amount%coins[pos]);\n }\n if(dp[amount][pos]!=-1) return dp[amount][pos];\n int skip = helper(amount...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "class Solution {\npublic:\n int n;\n int memo[301][5001];\n int changeUtil(vector<int> &coins, int amount, int idx){\n\n if(idx == n-1){\n if(amount % coins[idx] == 0){\n return 1;\n } return 0;\n }\n\n if(memo[idx][amount] != -1) return me...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "class Solution {\npublic:\n int dp[5001][301];\n int rec(vector<int>& coins,int amount,int n,int i){\n if(i>=n){\n if(amount==0) return 1;\n return 0;\n }\n if(dp[amount][i]!=-1) return dp[amount][i];\n int take =0;\n if(coins[i]<=amount){\n ...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "class Solution {\npublic:\n int n;\n int t[301][5001];\n \n int solve(int i, vector<int>& coins, int amount) {\n \n if(amount == 0)\n return t[i][amount] = 1;\n \n if(i == n || amount < 0)\n return 0;\n \n if(t[i][amount] != -1)\n...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "class Solution {\npublic:\n int dp[310][5010];\n int rec(int i,int rem,vector<int>& coins){\n if(rem==0) return 1;\n if(i==coins.size()){\n if(rem==0) return 1;\n return 0;\n }\n if(dp[i][rem]!=-1) return dp[i][rem];\n int ans=0;\n ans=a...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "class Solution {\npublic:\n int dp[310][5010];\n int rec(int i,int rem,vector<int>& coins){\n if(rem==0) return 1;\n if(i==coins.size()){\n if(rem==0) return 1;\n return 0;\n }\n if(dp[i][rem]!=-1) return dp[i][rem];\n int ans=0;\n ans=a...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "class Solution {\n int d[5555][330];\npublic:\n int change(int amount, vector<int>& coins) {\n memset(d,-1,sizeof(d));\n return dp(amount,coins.size()-1,coins);\n }\n int dp(int am,int ind,vector<int>& coins){\n if(am==0){\n return 1;\n }\n if(ind<0...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "class Solution {\npublic:\n int change(int amount, vector<int>& coins) {\n int memo[5001][301];\n memset(memo, -1, sizeof(memo));\n function<int(int, int)> dfs = [&](int amount, int index){\n if(amount == 0) return 1;\n if(amount < 0) return 0;\n if(index ...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "class Solution {\npublic:\n int change(int amount, vector<int>& coins) {\n int memo[5001][301];\n memset(memo, -1, sizeof(memo));\n function<int(int, int)> dfs = [&](int amount, int index){\n if(amount == 0) return 1;\n if(amount < 0) return 0;\n if(index ...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "class Solution {\npublic:\n int req;\n vector<int>a;\n int dp[400][5002];\n int n;\n int solve(int i,int sum){\n if(i >= n){\n if(sum == req){\n return 1;\n }\n return 0;\n }\n if(dp[i][sum] != -1)return dp[i][sum];\n ...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "class Solution {\npublic:\n int change(int amount, vector<int>& coins) {\n if(amount == 0) {\n return 1;\n }\n int sz = coins.size();\n vector<int> prev(amount + 1);\n \n \n for(auto i : coins) {\n if(i > amount) {\n c...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "class Solution {\npublic:\n int change(int amount, vector<int>& coins) {\n if(amount == 0) {\n return 1;\n }\n int sz = coins.size();\n vector<int> prev(amount + 1);\n \n \n for(auto i : coins) {\n if(i > amount) {\n c...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "class Solution {\npublic:\n int change(int amount, vector<int>& coins) {\n if(amount == 0) {\n return 1;\n }\n int sz = coins.size();\n vector<int> prev(amount + 1);\n \n \n for(auto i : coins) {\n if(i > amount) {\n c...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "class Solution {\npublic:\n int change(int amount, vector<int>& coins) {\n if(amount == 0) {\n return 1;\n }\n int sz = coins.size();\n vector<int> prev(amount + 1);\n \n \n for(auto i : coins) {\n if(i > amount) {\n c...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "class Solution {\npublic:\n int change(int amount, vector<int>& coins) {\n int n=coins.size();\n long long dp[n+1][amount+1];\n memset(dp,0,sizeof(dp));\n dp[0][0]=1;\n for(int j=0;j<n;j++){\n for(int i=0;i<=amount;i++){\n dp[j+1][i]+=dp[j][i];\n ...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "class Solution {\npublic:\n vector<vector<int>> dp; \n int solve(int ind, int amount, vector<int> &c) {\n if (amount == 0)\n return 1;\n if (ind == c.size() || amount < c[ind])\n return 0; \n if (dp[ind][amount] != -1)\n return dp[ind][amount]; \n...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "class Solution {\npublic:\n vector<vector<int>> dp; \n int solve(int ind, int amount, vector<int> &c) {\n // Whenever total ways are asked, return 1 if condition is satisfied, else 0 \n if (amount == 0)\n return 1;\n if (ind == c.size() || amount < c[ind])\n ...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "class Solution {\npublic:\n vector<vector<int>> dp; \n int maxi = INT_MAX; \n int solve(int ind, int amount, vector<int> &c) {\n if (amount == 0)\n return 1;\n if (ind == c.size() || amount < c[ind])\n return maxi; \n if (dp[ind][amount] != -1)\n ...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "class Solution {\npublic:\n int change(int amount, vector<int>& coins) {\n int n = coins.size();\n long long dp[n+1][amount+1];\n\n dp[0][0] = 1;\n for(int i = 1; i <= n; i++){\n dp[i][0] = 1;\n }\n\n for(int j = 1; j <=amount; j++){\n dp[0...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "class Solution {\npublic:\n int change(int amount, vector<int>& coins) {\n int a[400][6000]={0},i,j;\n for(i=0;i<=amount;i++){\n if(i%coins[0]==0)\n a[0][i]=1;\n }\n for(i=1;i<coins.size();i++){\n for(j=0;j<=amount;j++){\n if...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "class Solution {\npublic:\n int change(int amount, vector<int>& coins) {\n int a[400][6000]={0},i,j;\n for(i=0;i<coins.size();i++)\n a[i][0]=1;\n for(i=1;i<=amount;i++){\n if(i%coins[0]==0)\n a[0][i]=1;\n }\n for(i=1;i<coins.size();i++)...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "class Solution {\npublic:\n //Method - 01 (Memoization)\n int helper(int amount, int idx, vector<int>& coins, vector<vector<int>>& dp){\n if(amount == 0)\n return 1;\n if(idx < 0)\n return 0;\n if(amount < 0)\n return 0;\n if(dp[idx][amount...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "class Solution {\npublic:\n// int f(int ind, int amount, vector<int>& coins, vector<vector<int>>& dp){\n// if(ind == 0){\n// if(amount % coins[0] == 0) return 1;\n// return 0;\n// }\n// if(dp[ind][amount] != -1) return dp[ind][amount];\n// int nottake = f(ind-1, amount, ...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "class Solution {\npublic:\n\n int change(int amount, vector<int>& coins) {\n int n = coins.size();\n vector<int> prev(amount+1,0);\n\n for(int i=0 ; i<= amount ; i++){\n if(i%coins[0] == 0){\n prev[i] = 1;\n }\n }\n\n for(int index ...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
0
{ "code": "class Solution {\npublic:\n// int f(int ind, int amount, vector<int>& coins, vector<vector<int>>& dp){\n// if(ind == 0){\n// if(amount % coins[0] == 0) return 1;\n// return 0;\n// }\n// if(dp[ind][amount] != -1) return dp[ind][amount];\n// int nottake = f(ind-1, amount, ...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
2
{ "code": "class Solution {\npublic:\n\n int solve(vector<vector<int>>&dp, vector<int>&coins, int amount, int index)\n {\n if(amount==0)\n return 1;\n\n if(index<0)\n return 0;\n\n if(dp[index][amount] != -1)\n return dp[index][amount];\n\n int take =...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
2
{ "code": "class Solution {\npublic:\n int ways(int i, vector<int>& coins, int amt, vector<vector<int>>& dp) {\n\n if (i < 0)\n return 0;\n if (amt == 0)\n return 1;\n\n if (dp[i][amt] != -1)\n return dp[i][amt];\n\n int pick = 0;\n if (amt >= coi...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
3
{ "code": "class Solution {\npublic:\n int solve(int idx,int amt, vector<int>&coins,vector<vector<int>>&dp)\n {\n if(idx==coins.size()-1)\n {\n return (amt%coins[idx]==0);\n }\n\n if(dp[idx][amt]!=-1){\n return dp[idx][amt];\n }\n\n int not_pick=solve(id...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
3
{ "code": "class Solution {\npublic:\n int solve(int idx,int amt, vector<int>&coins,vector<vector<int>>&dp)\n {\n if(idx==coins.size()-1)\n {\n return (amt%coins[idx]==0);\n }\n\n if(dp[idx][amt]!=-1){\n return dp[idx][amt];\n }\n\n int not_pick=solve(id...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
3
{ "code": "int dp[10001][301]; \n \nclass Solution {\n\npublic:\n Solution() {\n ios_base::sync_with_stdio(false);\n cin.tie(0);\n cout.tie(0);\n }\n int solve(int i, int a, vector<int>& coins, int n, int k) {\n if (i == a)\n return 1;\n if (i >...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
3
{ "code": "class Solution {\npublic:\n int solve(int amount, vector<int>& coins,int i,vector<vector<int>> &dp)\n { \n \n if(i>=coins.size())\n { if(amount==0)\n {\n return 1;\n }\n return 0;\n\n }\n if(dp[i][amount]!=-1)\n {\n return dp[i][amount];\n }\n \n\n int include=0,exclu...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
3
{ "code": "class Solution {\npublic:\n\n int getans( int n , int sum , vector<int> &coins , vector<vector<int>> &dp )\n {\n if( sum == 0 && n == 0 )\n {\n return 1 ;\n }\n if( n == 0 )\n {\n return 0 ; \n }\n\n if( dp[n][sum] != -1 )\n ...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
3
{ "code": "class Solution {\npublic:\n int change(int amount, vector<int>& coins) {\n int f[3001][5001];\n f[0][0] = 1;\n for (int j = 1; j <= coins.size(); ++j) {\n f[j][0] = 1;\n for (int i = 1; i <= amount; ++i) {\n if (i < coins[j-1])\n ...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
3
{ "code": "class Solution {\npublic:\n int t;\n int length;\n\n int rec(int level, long long taken, vector<int>& coins,vector<vector<int>>& dp) {\n\n // pruning\n if (taken > t || level == length)\n return 0;\n\n // base case\n if (taken == t)\n return 1;\n\n...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
3
{ "code": "class Solution {\npublic:\n int mod = 1e9 + 7;\n long long dp[301][5001];\n long long rec(int level,int left,vector<int>& c){\n if(left < 0) return 0;\n \n if(level == c.size()){\n if(left == 0) return 1;\n else return 0;\n }\n\n if(dp[level...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
3
{ "code": "class Solution {\npublic:\n int change(int amount, vector<int>& coins) {\n int n = coins.size();\n std::vector<std::vector<int>> memo(n, std::vector<int>(amount + 1, -1));\n\n std::function<int(int, int)> dfs = [&](int remain, int i) -> int {\n if (remain == 0) {\n ...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
3
{ "code": "class Solution {\npublic:\n int change(int amount, vector<int>& coins) {\n int n = coins.size();\n std::vector<std::vector<int>> memo(n, std::vector<int>(amount + 1, -1));\n\n std::function<int(int, int)> dfs = [&](int remain, int i) -> int {\n if (remain == 0) {\n ...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
3
{ "code": "class Solution {\npublic:\n int dp[310][10010];\n \n int func(int ind, int amount, vector<int> & coins){\n if(amount == 0) return 1;\n if(ind < 0) return 0;\n if(dp[ind][amount] != -1) return dp[ind][amount];\n \n int ways = 0;\n for(int coin_amount = 0; c...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
3
{ "code": "\n\n\n\nstruct combinations {\npublic:\n\tinline static int get(std::vector<int> const &coins, int target) {\n\t\tint const n = coins.size();\n\t\tstd::vector<std::vector<int>> dp(n + 1, std::vector<int>(target + 1, -1));\n\t\tstd::function<int(int const&, int const&)> rx = [&](int const &index, int const ...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
3
{ "code": "class Solution {\npublic:\n int change(int amount, vector<int>& coins) {\n int dp[310][10010];\n memset(dp, -1, sizeof(dp));\n int n = coins.size();\n return solve(coins, amount, n, dp);\n }\n\n int solve(vector<int>& coins, int amount, int n, int dp[][10010]) {\n ...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
3
{ "code": "class Solution {\npublic:\n int change(int amount, vector<int>& coins) {\n int dp[310][10010];\n memset(dp, -1, sizeof(dp));\n int n = coins.size();\n return solve(coins, amount, n-1, dp);\n }\n\n int solve(vector<int>& coins, int amount, int n, int dp[][10010]) {\n ...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
3
{ "code": "class Solution {\npublic:\n int change(int amount, vector<int>& coins) {\n // if i - coins[j] >= 0:\n // coins[j] can be used(exclude or include)\n \n // if i - coins[j] < 0\n // coins[j] cannot be used(exclude)\n vector<vector<int>>dp(amount + 1, vector<int>(co...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
3
{ "code": "class Solution {\npublic:\n\n int helper(vector<int>& coins, int amount, int idx) {\n int n = coins.size();\n vector<vector<int>> dp(amount + 1, vector<int>(n, 0));\n\n for (int tar = 0; tar <= amount; tar++) {\n for(int i = 0; i < n; i++) {\n if (tar == 0)...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
3
{ "code": "class Solution {\npublic:\n \n int countways(int amount,vector<int>&coins,int n,vector<vector<int>>&dp){\n if(amount==0)return 1;\n if(n<0)return 0;\n if(dp[amount][n]!=-1)return dp[amount][n];\n int take=0;\n if(amount>=coins[n])take=countways(amount-coins[n],coins...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
3
{ "code": "class Solution {\npublic:\n\n int helper(vector<int>& coins, int amount, int idx) {\n int n = coins.size();\n vector<vector<int>> dp(amount + 1, vector<int>(n, 0));\n\n for (int tar = 0; tar <= amount; tar++) {\n for(int i = 0; i < n; i++) {\n if (tar == 0)...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
3
{ "code": "class Solution {\npublic:\n vector<vector<int>>dp;\n int solve(int amount, vector<int>&coins, int index) {\n if (amount == 0) return 1;\n if (amount < 0) return 0;\n if (index >= coins.size()) return 0;\n int res = 0;\n if (dp[amount][index] != -1) return dp[amount]...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
3
{ "code": "class Solution {\npublic:\n \n int countways(int amount,vector<int>&coins,int n,vector<vector<int>>&dp){\n if(amount==0)return 1;\n if(n<0)return 0;\n if(dp[amount][n]!=-1)return dp[amount][n];\n int take=0;\n if(amount>=coins[n])take=countways(amount-coins[n],coins...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
3
{ "code": "class Solution {\npublic:\n int Count(std::vector<int>& coins, int total, int idx, std::vector<std::vector<int>>* const dp) {\n if (total == 0) {\n return 1;\n }\n if (idx == coins.size() || total < 0) {\n return 0;\n }\n\n if ((*dp)[total][idx] =...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
3
{ "code": "class Solution {\npublic:\n int solve(vector<int>& coins, vector<vector<int>>& dp, int i, int amt){\n // if(i==coins.size()){\n // if(amt == 0) return 1;\n // else return 0;\n // }\n if(i>=coins.size()) return 0;\n if(amt == 0) return 1;\n if(amt<...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
3
{ "code": "class Solution {\npublic:\n\n int changeHelper(int amount, vector<int>& coins, map<pair<int, int>, int> &dp_memo, int index)\n {\n if(amount == 0)\n return 1;\n if(amount < 0)\n return 0;\n\n pair<int, int> d = make_pair(amount, index);\n if(dp_memo.f...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
3
{ "code": "class Solution {\npublic:\n int change(int amount, vector<int>& coins) {\n auto memo = vector(amount + 1, vector(coins.size() + 1, -1));\n function<int(int, int)> f = [&](int s, int k) {\n assert(s >= 0);\n assert(k >= 0);\n if (k == 0)\n ret...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
3
{ "code": "class Solution {\npublic:\n\n int changeHelper(int amount, const vector<int>& coins, const int &coinCount, map<pair<int, int>, int> &dp_memo, int index)\n {\n if(amount == 0)\n return 1;\n if(amount < 0)\n return 0;\n\n pair<int, int> d = make_pair(amount, i...
518
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
3
{ "code": "class Solution {\n\npublic:\n\n int changeHelper(int amount, const vector<int>& coins, const int &coinCount, map<pair<int, int>, int> &dp_memo, int index)\n {\n if(amount == 0)\n return 1;\n if(amount < 0)\n return 0;\n\n pair<int, int> d = make_pair(amount,...