+ 3

[SOLVED] Code coach Q-sequence

My code pass the first two tests and then fails. I can't figure out the reason. https://code.sololearn.com/c3id5Vl0sDVK/?ref=app

10th Nov 2020, 11:15 PM
Davide
Davide - avatar
4 Respostas
+ 2
In this code coach you can't use recursive like that because when the input is too big (34 I remember), the code won't output anything because of time exceed.
10th Nov 2020, 11:19 PM
äœ çŸ„é“èŠć‰‡ïŒŒæˆ‘äčŸæ˜Ż
äœ çŸ„é“èŠć‰‡ïŒŒæˆ‘äčŸæ˜Ż - avatar
+ 6
To many unnecessary calculations making time limit exceed. The function is called with the same argument many times, resulting in the same recursive calculations to compute over and over. Try to break it down using paper and pencil. Solutions: 1-) Use memoization 2-) Write the code in iterative fashion <- easy and my recommended solution.
10th Nov 2020, 11:22 PM
Kevin ★
+ 2
Kevin ★ thank you as well đŸ™đŸ€— I am going to do it 😎
10th Nov 2020, 11:25 PM
Davide
Davide - avatar
+ 1
They could warn users about that. You can't leave people looking for a bug that doesn't exist 😭😭😭 Anyway thank you so much CarrieForle đŸ™đŸ€—
10th Nov 2020, 11:24 PM
Davide
Davide - avatar