Can someone please tell me, on which case does my code fail for July Long Challenge Question, Optimal Denomination (CodeChef: Practical coding for everyone)
CodeChef: Practical coding for everyone
Your code will fail for below test case
4
6 2 30 42
In your code, for this test case, pref[n-1] would be 2 and your code will print the answer as 20.
But optimally, we can change the salary of employee at index 1 from 2 to 6 (New Salaries [6,6,30,42]) and then we will pay all the salaries with denomination value as 6 and the minimum number of notes required will be 14
1 Like