We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
public static String CoinChange(int input1,int[] input2,int a, HashMap<String,Long> memo)
{
int b = 1;
int c = 0;
long d = 0;
String x = "";
if(input1 == 0)
{
return (x = String.valueOf(b));
}
if(a >= input2.length)
{
return (x = String.valueOf(c));
}
String z = input1+"-"+a;
if(memo.containsKey(z))
{
d = memo.get(z);
return (x = String.valueOf(d));
}
int e = 0;
long f = 0;
while(e <= input1)
{
int g = input1 - e;
f += CoinChange(input2, g, a+1,memo);
e += input2[a];
}
memo.put(z,f);
return(x = String.valueOf(f));
and i was getting a error which is
CandidateCode.java:43: error: incompatible types: int[] cannot be converted to int
f += CoinChange(input2, g, a+1,memo);
can anyone please solve this
The Coin Change Problem
You are viewing a single comment's thread. Return to all comments →
this is my code and used java8 :- for coin change problem
public static String CoinChange(int input1,int[] input2) { return CoinChange(input1,input2,0,new HashMap()); }