Code ran for PYPY3 but gave runtime error for Python3

During August long challenge I ran https://www.codechef.com/viewsolution/36735765 code for CHEFWED problem. It gave runtime error for python 3 but ran fine for pypy3.
Can someone explain why?

I didn’t see your whole code, but I guess the cause can be deep recursion.

1 Like

So, should I practice dynamic programming without recursion or use different language in future competition? @harshraj22 .

  • Switching to languages like c++ / java might really help (but keep in mind, language can’t hinder if you are good enough, and pagenegod is example who uses python still has achieved great)
  • Iterative DP would be definitely helpful compared to recursive dp, and you will also need to learn dfs/ tree traversals using stack/ iteration if deep recursion is a problem. :wink:
  • You can use bootstrap decorator (copy code to your file and read docs to understand how to use it) from pyrival for deep recursion with python. It is really helpful given that your preffered website supports it .
2 Likes