is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.
CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.
Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.
Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.
based on limited knapsack problem.
- Pranav Gupta October 16, 2020public class CoinChangeLimitedSupply {
public static void main(String[] args) throws java.lang.Exception {
int[] coins = { 1, 2, 4, 8 };
int[] count = { 2, 2, 2, 2 };
int sum = 9;
int n = countWays(coins, count, sum);
System.out.println(n);
}
/**
* Coin change problem with finite number of coins available denominations
* of coins = {1,2,3} count of coins = ={1,1,3} find the number of ways for
* getting change for S=6
*/
public static int countWays(int[] coins, int[] count, int sum) {
int n = coins.length;
int[][] dp = new int[n + 1][sum + 1];
int ret = 0;
dp[0][0] = 1;
for (int j = 1; j <= n; j++) {
for (int i = 0; i <= sum; i++) {
dp[j][i] += dp[j-1][i];
}
for (int k = 1; k <= count[j - 1]; k++) {
int initial = coins[j - 1] * k;
for (int i = initial; i <= sum; i++) {
dp[j][i] += dp[j-1][i - initial];
}
}
}
for(int i=0; i<=n; i++) {
for(int j=0; j<=sum; j++) {
System.out.print(dp[i][j] + " ");
}
System.out.println("");
}
// for (int i = 0; i <= n; i++) {
// ret += dp[i][sum];
// }
return dp[n][sum];
}
}