[SOLVED] Code coach Q-sequence | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 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