You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//Note : This problem is similar to count of subset sum but only the difference is that the repetition of same elements are allowed.
6
+
7
+
// Given a value N, find the number of ways to make change for N cents, if we have infinite supply of each of S = { S1, S2, .. , SM } valued coins.
8
+
9
+
10
+
// Example 1:
11
+
12
+
// Input:
13
+
// n = 4 , m = 3
14
+
// S[] = {1,2,3}
15
+
// Output: 4
16
+
// Explanation: Four Possible ways are:
17
+
// {1,1,1,1},{1,1,2},{2,2},{1,3}.
18
+
// Example 2:
19
+
20
+
// Input:
21
+
// n = 10 , m = 4
22
+
// S[] ={2,5,3,6}
23
+
// Output: 5
24
+
// Explanation: Five Possible ways are:
25
+
// {2,2,2,2,2}, {2,2,3,3}, {2,2,6}, {2,3,5}
26
+
// and {5,5}.
27
+
28
+
// Your Task:
29
+
// You don't need to read input or print anything. Your task is to complete the function count() which accepts an array S[] its size m and n as input parameter and returns the number of ways to make change for N cents.
0 commit comments