+ 2
Why this code is failing Test Cases 3 to 6? This is Hofstadter's Q-Sequence problem from 'Hard' section.
3 Antworten
+ 5
https://www.sololearn.com/Discuss/2119714/?ref=app
https://www.sololearn.com/Discuss/2146525/?ref=app
edit :
Hari Shankar there is one more way to solve this by setting the recursion limit 👍
+ 2
You can evade the recursion problem by coding an iterative version of the algo. It will be quicker and doesn't shut down at depth 993 or what it was.
The basic idea: Instead of recreating all the values every time recursively, store them in an array and just access them.
+ 1
I tried to use numpy array to store values. Because of this I passed test case 4 & 5. But still I am not able to pass test case 6. What can be wrong? Here is the code
https://code.sololearn.com/c3TL6Ns605Yw/?ref=app