+ 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 Answers
+ 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