0

How to improve it's algorithm

Yeah if I input a large num,it timed out.So anyone help me to improve it's algorithm!Thanks https://code.sololearn.com/cbblP6b9x5mS/?ref=app

1st Oct 2020, 12:10 AM
Sherry_Lim
Sherry_Lim - avatar
4 Answers
+ 2
Shirt it is a classical dynamic programming problem. Here is the solution 👇 time complexity = O(n) auxiliary space required is also O(n) https://code.sololearn.com/cuG06qK3ru9B/?ref=app
1st Oct 2020, 4:31 AM
Arsenic
Arsenic - avatar
+ 2
How can we improvise the algorithm if we don't know what exactly is the question ?
1st Oct 2020, 12:29 AM
Arsenic
Arsenic - avatar
+ 2
Thanks bro you are so cool
1st Oct 2020, 4:47 AM
Sherry_Lim
Sherry_Lim - avatar
+ 1
Ops I forget 😅 the question is one day you wemt shopping and shopkeeper gave you %d 💰 (such as 20);and you only can choose 1$,5$,20$ three types .the question is it has how many combinations? (20 money have 6 combinations)
1st Oct 2020, 1:55 AM
Sherry_Lim
Sherry_Lim - avatar