Failing in the efficiency test


My code completed the correctness test but fails the efficiency test with a runtime Error (StackOverflow).
What can be the possible reason?


Maybe your return value contains a cycle. Make sure to check for all the possible cases.


Try to reverse list using INPLACE ALGO or iteratively.